"use client"; import { RouterAdminEvent } from "@/app/lib/router_admin/router_admin_event"; import { apiGetEventRiwayatCount, apiGetEventStatusCountDashboard, apiGetEventTipeAcara, } from "@/app/dev/admin/event/_lib/api_fecth_admin_event"; import global_limit from "@/app/lib/limit"; import { AccentColor, MainColor } from "@/app_modules/_global/color"; import { AdminColor } from "@/app_modules/_global/color/color_pallet"; import CustomSkeleton from "@/app_modules/components/CustomSkeleton"; import { clientLogger } from "@/util/clientLogger"; import { Flex, Paper, SimpleGrid, Stack, Text, ThemeIcon, Title, } from "@mantine/core"; import { useShallowEffect } from "@mantine/hooks"; import { IconAlertTriangle, IconBookmark, IconBriefcase, IconHistory, IconUpload, } from "@tabler/icons-react"; import { useRouter } from "next/navigation"; import { useState } from "react"; import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate"; export default function AdminEvent_Main() { const router = useRouter(); const [countPublish, setCountPublish] = useState(null); const [countReview, setCountReview] = useState(null); const [countReject, setCountReject] = useState(null); const [countTipeAcara, setCountTipeAcara] = useState(null); const [countRiwayat, setCountRiwayat] = useState(null); useShallowEffect(() => { handlerLoadData(); }, []); async function handlerLoadData() { try { const listLoadData = [ global_limit(() => onLoadCountPublish()), global_limit(() => onLoadCountReview()), global_limit(() => onLoadCountReject()), global_limit(() => onLoadCountRiwayat()), global_limit(() => onLoadCountTipeAcara()), ]; const result = await Promise.all(listLoadData); } catch (error) { clientLogger.error("Error handler load data", error); } } async function onLoadCountPublish() { try { const respone = await apiGetEventStatusCountDashboard({ name: "Publish", }); if (respone) { setCountPublish(respone.data); } } catch (error) { clientLogger.error("Error get count publish", error); } } async function onLoadCountReview() { try { const respone = await apiGetEventStatusCountDashboard({ name: "Review", }); if (respone) { setCountReview(respone.data); } } catch (error) { clientLogger.error("Error get count review", error); } } async function onLoadCountReject() { try { const respone = await apiGetEventStatusCountDashboard({ name: "Reject", }); if (respone) { setCountReject(respone.data); } } catch (error) { clientLogger.error("Error get count reject", error); } } async function onLoadCountRiwayat() { try { const respone = await apiGetEventRiwayatCount(); if (respone) { setCountRiwayat(respone.data); } } catch (error) { clientLogger.error("Error get count riwayat", error); } } async function onLoadCountTipeAcara() { try { const respone = await apiGetEventTipeAcara(); if (respone) { setCountTipeAcara(respone.data); } } catch (error) { clientLogger.error("Error get count tipe acara", error); } } const listStatus = [ { id: 1, name: "Publish", jumlah: countPublish == null ? ( ) : countPublish ? ( countPublish ) : ( "-" ), path: RouterAdminEvent.table_publish, color: MainColor.green, icon: , }, { id: 2, name: "Review", jumlah: countReview == null ? ( ) : countReview ? ( countReview ) : ( "-" ), path: RouterAdminEvent.table_review, color: MainColor.orange, icon: , }, { id: 3, name: "Reject", jumlah: countReject == null ? ( ) : countReject ? ( countReject ) : ( "-" ), path: RouterAdminEvent.table_reject, color: MainColor.red, icon: , }, { id: 4, name: "Riwayat Event", jumlah: countRiwayat == null ? ( ) : countRiwayat ? ( countRiwayat ) : ( "-" ), path: RouterAdminEvent.table_publish, color: AccentColor.softblue, icon: , }, ]; const listBox2 = [ { id: 1, name: "Tipe Acara", jumlah: countTipeAcara == null ? ( ) : countTipeAcara ? ( countTipeAcara ) : ( "-" ), path: RouterAdminEvent.table_publish, color: "#A888E2", icon: , }, ]; return ( <> {listStatus.map((e, i) => ( {e.name} {e.jumlah} {e.icon} ))} {listBox2.map((e, i) => ( {e.name} {e.jumlah} {e.icon} ))} ); }