Files
hipmi-mobile/service/api-client/api-event.ts
Bagasbanuna02 1bcd1a044f Integrasi API: Event Type
Add:
- utils/colorActivationForBadge.ts

Fix:
- app/(application)/admin/event/type-create.tsx
- app/(application)/admin/event/type-of-event.tsx
- app/(application)/admin/event/type-update.tsx
- service/api-admin/api-admin-event.ts
- service/api-admin/api-master-admin.ts
- service/api-client/api-event.ts

### No Issue
2025-10-24 16:22:45 +08:00

182 lines
3.5 KiB
TypeScript

import { apiConfig } from "../api-config";
export async function apiEventCreate(data: any) {
try {
const response = await apiConfig.post(`/mobile/event`, {
data: data,
});
return response.data;
} catch (error) {
throw error;
}
}
export async function apiEventGetByStatus({
id,
status,
}: {
id: string;
status: string;
}) {
try {
const response = await apiConfig.get(`/mobile/event/${id}/${status}`);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiEventGetOne({ id }: { id: string }) {
try {
const response = await apiConfig.get(`/mobile/event/${id}`);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiEventUpdateStatus({
id,
status,
}: {
id: string;
status: "draft" | "review" | "publish" | "reject";
}) {
try {
const response = await apiConfig.put(`/mobile/event/${id}/${status}`);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiEventUpdateData({
id,
data,
}: {
id: string;
data: any;
}) {
try {
const response = await apiConfig.put(`/mobile/event/${id}`, {
data: data,
});
return response.data;
} catch (error) {
throw error;
}
}
export async function apiEventDelete({ id }: { id: string }) {
try {
const response = await apiConfig.delete(`/mobile/event/${id}`);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiEventGetAll({
category,
userId,
}: {
category?: "beranda" | "contribution" | "all-history" | "my-history";
userId?: string;
}) {
try {
const categoryEvent = category ? `?category=${category}` : "";
const userIdCreator = userId ? `&userId=${userId}` : "";
const response = await apiConfig.get(
`/mobile/event${categoryEvent}${userIdCreator}`
);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiEventJoin({
id,
userId,
}: {
id: string;
userId?: string;
}) {
try {
const response = await apiConfig.post(`/mobile/event/${id}/participants`, {
userId: userId,
});
return response.data;
} catch (error) {
throw error;
}
}
export async function apiEventListOfParticipants({ id }: { id?: string }) {
try {
const response = await apiConfig.get(`/mobile/event/${id}/participants`);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiEventCheckParticipants({
id,
userId,
}: {
id: string;
userId?: string;
}) {
try {
const selectUserId = userId ? `?userId=${userId}` : "";
const response = await apiConfig.get(
`/mobile/event/${id}/check-participants${selectUserId}`
);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiEventGetConfirmation({
id,
userId,
}: {
id: string;
userId?: string;
}) {
try {
const response = await apiConfig.get(`/mobile/event/${id}/confirmation?userId=${userId}`);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiEventConfirmationAction({
id,
userId,
category,
}: {
id: string;
userId?: string;
category?: "join_and_confirm" | "confirmation";
}) {
try {
const response = await apiConfig.post(
`/mobile/event/${id}/confirmation?category=${category}`,
{
data: {
userId: userId,
},
}
);
return response.data;
} catch (error) {
throw error;
}
}