fix admin event

deskripsi:
- fix server action to API
This commit is contained in:
2025-01-30 17:51:34 +08:00
parent 958a9e1be6
commit 5cc4728cad
5 changed files with 353 additions and 206 deletions

View File

@@ -2,6 +2,7 @@ export {
apiGetEventStatusCountDashboard,
apiGetEventTipeAcara,
apiGetEventRiwayatCount,
apiGetDataEventByStatus,
};
const apiGetEventStatusCountDashboard = async ({
@@ -26,25 +27,25 @@ const apiGetEventStatusCountDashboard = async ({
};
const apiGetEventRiwayatCount = async () => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/admin/event/dashboard/riwayat`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
});
const response = await fetch(`/api/admin/event/dashboard/riwayat`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
});
return await response.json().catch(() => null);
}
return await response.json().catch(() => null);
};
const apiGetEventTipeAcara = async () => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/admin/event/dashboard/tipe-acara`, {
method: "GET",
@@ -54,7 +55,33 @@ const apiGetEventTipeAcara = async () => {
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
});
});
return await response.json().catch(() => null);
};
const apiGetDataEventByStatus = async ({
status,
page,
search,
}: {
status: "Publish" | "Review" | "Reject";
page: string;
search: string;
}) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
const isPage = page ? `?page=${page}` : "";
const isSearch = search ? `&search=${search}` : "";
const respone = await fetch(`/api/admin/event/${status}${isPage}${isSearch}`, {
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
});
return await respone.json().catch(() => null);
};

View File

@@ -2,11 +2,9 @@ import { AdminEvent_TablePublish } from "@/app_modules/admin/event";
import { adminEvent_funGetListPublish } from "@/app_modules/admin/event/fun";
async function Page() {
const listPublish = await adminEvent_funGetListPublish({ page: 1 });
return (
<>
<AdminEvent_TablePublish listPublish={listPublish as any} />
<AdminEvent_TablePublish />
</>
);
}