import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog"; import { AccentColor, MainColor } from "@/app_modules/_global/color"; import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data"; import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global"; import CustomSkeleton from "@/app_modules/components/CustomSkeleton"; import { ActionIcon, Box, Flex, Grid, Group, Image, Paper, SimpleGrid, Stack, Text, } from "@mantine/core"; import { useShallowEffect } from "@mantine/hooks"; import { IconUserSearch } from "@tabler/icons-react"; import _ from "lodash"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { apiGetDataHome } from "../fun/get/api_home"; import { listMenuHomeBody, menuHomeJob } from "./list_menu_home"; import { clientLogger } from "@/util/clientLogger"; export default function BodyHome() { const router = useRouter(); const [dataUser, setDataUser] = useState({}); const [dataJob, setDataJob] = useState([]); const [loadingJob, setLoadingJob] = useState(true); const [loading, setLoading] = useState(true); useShallowEffect(() => { cekUserLogin(); getHomeJob(); }, []); async function cekUserLogin() { try { const response = await apiGetDataHome({ path: "?cat=cek_profile", }); if (response) { setDataUser(response.data); } } catch (error) { clientLogger.error("Error get data user", error); } } async function getHomeJob() { try { setLoadingJob(true); const response = await apiGetDataHome({ path: "?cat=job", }); if (response) { setDataJob(response.data); } } catch (error) { clientLogger.error("Error get data job", error); } finally { setLoadingJob(false); } } return ( {/* */} logo setLoading(false)} styles={{ imageWrapper: { border: `2px solid ${AccentColor.blue}`, borderRadius: "10px 10px 10px 10px", }, image: { borderRadius: "8px 8px 8px 8px", }, }} /> {listMenuHomeBody.map((e, i) => ( { if ( dataUser.profile == undefined || dataUser?.profile == null || dataJob.length == undefined || dataJob.length == null ) { return null; } else if ( dataUser.profile == undefined || dataUser?.profile == null ) { router.push(RouterProfile.create, { scroll: false }); } else { if (e.link == "") { return ComponentGlobal_NotifikasiPeringatan( "Cooming Soon !!" ); } else { router.push(e.link, { scroll: false }); } } }} > {e.icon} {e.name} ))} {/* Job View */} { if ( dataUser.profile == undefined || dataUser?.profile == null || dataJob.length == undefined || dataJob.length == null ) { return null; } else if ( dataUser.profile == undefined || dataUser?.profile == null ) { router.push(RouterProfile.create, { scroll: false }); } else { if (menuHomeJob.link == "") { return ComponentGlobal_NotifikasiPeringatan( "Cooming Soon !!" ); } else { return router.push(menuHomeJob.link, { scroll: false }); } } }} > {menuHomeJob.icon} {menuHomeJob.name} {loadingJob ? ( Array(1) .fill(null) .map((_, i) => ( )) ) : _.isEmpty(dataJob) ? ( ) : ( {dataJob.map((e, i) => ( {e?.Author.username} {e?.title} ))} )} ); }