API Event
Add: - api-client/api-event : fetch get one, update data, update status, create event Fix: - UI : create , detail dan status: untuk menyambungkan ke API ### No Issue
This commit is contained in:
64
service/api-client/api-event.ts
Normal file
64
service/api-client/api-event.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
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}`);
|
||||
console.log("[SUCCESS]", response.data);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
// console.log("[ERROR FECTH]", 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user