"use client"; import { Flex, Group, Paper, SimpleGrid, Stack, Text, ThemeIcon, Title } from "@mantine/core"; import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { clientLogger } from "@/util/clientLogger"; import { IconAlertTriangle, IconArchive, IconBookmark, IconUpload } from "@tabler/icons-react"; import { AccentColor } from "@/app_modules/_global/color"; import { AdminColor } from "@/app_modules/_global/color/color_pallet"; import CustomSkeleton from "@/app_modules/components/CustomSkeleton"; import global_limit from "@/lib/limit"; import { useShallowEffect } from "@mantine/hooks"; import { apiGetJobArsipCount, apiGetJobStatusCountDashboard } from "../lib/api_fetch_admin_job"; export default function AdminJob_Main() { const [countPublish, setCountPublish] = useState(null); const [countReview, setCountReview] = useState(null); const [countReject, setCountReject] = useState(null); const [countArsip, setCountArsip] = useState(null); const router = useRouter(); useShallowEffect(() => { handlerLoadData(); }, []); async function handlerLoadData() { try { const listLoadData = [ global_limit(() => onLoadCountPublish()), global_limit(() => onLoadCountReview()), global_limit(() => onLoadCountReject()), global_limit(() => onLoadCountArsip()), ] } catch (error) { clientLogger.error("Error handler load data", error) } } async function onLoadCountPublish() { try { const response = await apiGetJobStatusCountDashboard({ name: "Publish", }) if (response) { setCountPublish(response.data); } } catch (error) { clientLogger.error("Error get count publish", error) } } async function onLoadCountReview() { try { const response = await apiGetJobStatusCountDashboard({ name: "Review", }) if (response) { setCountReview(response.data); } } catch (error) { clientLogger.error("Error get count review", error) } } async function onLoadCountReject() { try { const response = await apiGetJobStatusCountDashboard({ name: "Reject", }) if (response) { setCountReject(response.data); } } catch (error) { clientLogger.error("Error get count reject", error) } } async function onLoadCountArsip() { try { const response = await apiGetJobArsipCount() if (response) { setCountArsip(response.data); } } catch (error) { clientLogger.error("Error get count arsip", error) } } const listStatus = [ { id: 1, name: "Publish", jumlah: countPublish == null ? ( ) : countPublish ? ( countPublish ) : ( "-" ), color: "green", text_color: "white", icon: }, { id: 2, name: "Review", jumlah: countReview == null ? ( ) : countReview ? ( countReview ) : ( "-" ), color: "orange", text_color: "white", icon: }, { id: 3, name: "Reject", jumlah: countReject == null ? ( ) : countReject ? ( countReject ) : ( "-" ), color: "red", text_color: "white", icon: }, { id: 4, name: "Arsip", jumlah: countArsip == null ? ( ) : countArsip ? ( countArsip ) : ( "-" ), color: "gray", text_color: "white", icon: }, ]; return ( <> {listStatus.map((e, i) => ( {e.name} {e.jumlah ? e.jumlah : 0} {e.icon} ))} ); }