API Dashboard Investasi & Event
This commit is contained in:
60
src/app/dev/admin/event/_lib/api_fecth_admin_event.ts
Normal file
60
src/app/dev/admin/event/_lib/api_fecth_admin_event.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
export {
|
||||
apiGetEventStatusCountDashboard,
|
||||
apiGetEventTipeAcara,
|
||||
apiGetEventRiwayatCount,
|
||||
};
|
||||
|
||||
const apiGetEventStatusCountDashboard = async ({
|
||||
name,
|
||||
}: {
|
||||
name: "Publish" | "Review" | "Reject";
|
||||
}) => {
|
||||
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/${name}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
};
|
||||
|
||||
const apiGetEventRiwayatCount = async () => {
|
||||
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}`,
|
||||
},
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
const response = await fetch(`/api/admin/event/dashboard/tipe-acara`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
};
|
||||
@@ -1,26 +1,9 @@
|
||||
import { AdminEvent_Main } from "@/app_modules/admin/event";
|
||||
import AdminEvent_funCountByStatusId from "@/app_modules/admin/event/fun/count/fun_count_event_by_status_id";
|
||||
import { AdminEvent_funCountRiwayat } from "@/app_modules/admin/event/fun/count/fun_count_riwayat";
|
||||
import { AdminEvent_funCountTipeAcara } from "@/app_modules/admin/event/fun/count/fun_count_tipe_acara";
|
||||
|
||||
export default async function Page() {
|
||||
const countPublish = await AdminEvent_funCountByStatusId("1");
|
||||
const countReview = await AdminEvent_funCountByStatusId("2");
|
||||
const countDraft = await AdminEvent_funCountByStatusId("3");
|
||||
const countReject = await AdminEvent_funCountByStatusId("4");
|
||||
const countTipeAcara = await AdminEvent_funCountTipeAcara();
|
||||
const countRiwayat = await AdminEvent_funCountRiwayat();
|
||||
|
||||
return (
|
||||
<>
|
||||
<AdminEvent_Main
|
||||
countPublish={countPublish as number}
|
||||
countReview={countReview as number}
|
||||
countDraft={countDraft as number}
|
||||
countReject={countReject as number}
|
||||
countTipeAcara={countTipeAcara as number}
|
||||
countRiwayat={countRiwayat}
|
||||
/>
|
||||
<AdminEvent_Main />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ import Admin_getTotalInvestasiByUser from "@/app_modules/admin/investasi/fun/get
|
||||
|
||||
export default async function Page() {
|
||||
const listInvestasi = await Admin_funGetAllInvestasi();
|
||||
const countDraft = await Admin_CountStatusInvestasi(1);
|
||||
const countReview = await Admin_CountStatusInvestasi(2);
|
||||
const countPublish = await Admin_CountStatusInvestasi(3);
|
||||
const countReject = await Admin_CountStatusInvestasi(4);
|
||||
// const countDraft = await Admin_CountStatusInvestasi(1);
|
||||
// const countReview = await Admin_CountStatusInvestasi(2);
|
||||
// const countPublish = await Admin_CountStatusInvestasi(3);
|
||||
// const countReject = await Admin_CountStatusInvestasi(4);
|
||||
const totalInvestasiByUser = await Admin_getTotalInvestasiByUser()
|
||||
const publishProgres = await Admin_getPublishProgresInvestasi()
|
||||
// console.log(targetTerbesar)
|
||||
@@ -18,10 +18,10 @@ export default async function Page() {
|
||||
<>
|
||||
<Admin_Investasi
|
||||
listInvestasi={listInvestasi as any}
|
||||
countDraft={countDraft}
|
||||
countReview={countReview}
|
||||
countPublish={countPublish}
|
||||
countReject={countReject}
|
||||
// countDraft={countDraft}
|
||||
// countReview={countReview}
|
||||
// countPublish={countPublish}
|
||||
// countReject={countReject}
|
||||
totalInvestasiByUser={totalInvestasiByUser}
|
||||
publishProgres={publishProgres}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user