"use client"; import { AccentColor, MainColor } from "@/app_modules/_global/color"; import { apiGetUserById } from "@/app_modules/_global/lib/api_user"; import { MODEL_USER } from "@/app_modules/home/model/interface"; import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface"; import { gs_admin_ntf } from "@/lib/global_state"; import { AppShell, Burger, Divider, Drawer, Group, Header, MediaQuery, Navbar, ScrollArea, Stack, Text, useMantineTheme, } from "@mantine/core"; import { useDisclosure, useShallowEffect } from "@mantine/hooks"; import { IconBriefcase, IconCoin, IconHome, IconMessage, IconUser, } from "@tabler/icons-react"; import { useAtom } from "jotai"; import { usePathname, useRouter } from "next/navigation"; import type React from "react"; import { useState } from "react"; import { Admin_UiNavbar } from "../_admin_global"; import { gs_admin_navbar_menu, gs_admin_navbar_subMenu, } from "../_admin_global/new_global_state"; import { Admin_V3_ComponentButtonUserCircle } from "./comp_button_user_circle"; import { Admin_V3_SkeletonNavbar } from "./skeleton_navbar"; import { Admin_V3_ViewDrawerNotifikasi } from "./notifikasi/view_drawer_notifikasi"; export function Admin_V3_MainLayout({ children, userLoginId, countNotifikasi, version, }: { children: React.ReactNode; userLoginId: string; countNotifikasi: number; version: string; }) { const [dataUser, setDataUser] = useState(null); const userRoleId = dataUser?.masterUserRoleId; const [activeId, setActiveId] = useAtom(gs_admin_navbar_menu); const [activeChildId, setActiveChildId] = useAtom(gs_admin_navbar_subMenu); // Notifikasi const [countNtf, setCountNtf] = useState(countNotifikasi); const [newAdminNtf, setNewAdminNtf] = useAtom(gs_admin_ntf); useShallowEffect(() => { handleLoadUser(); }, []); async function handleLoadUser() { try { const response = await apiGetUserById({ id: userLoginId }); if (response && response.success) { setDataUser(response.data); } else { console.error("Failed to fetch user data", response); setDataUser(null); } } catch (error) { console.error("Error fetching user data", error); setDataUser(null); } } const [openPop, setOpenPop] = useState(false); const [opened, handlers] = useDisclosure(false); const [openedDrawer, handlersDrawer] = useDisclosure(false); return ( <> Notifikasi } opened={openedDrawer} onClose={handlersDrawer.toggle} position="right" size={"sm"} > { setActiveId(val.id as any); setActiveChildId(val.childId); }} onToggleNavbar={(val: any) => { val === false && handlersDrawer.close(); }} /> {/* { setActiveId(val.id as any); setActiveChildId(val.childId); }} onToggleNavbar={(val: any) => { setDrawerNotifikasi(val); }} onLoadCountNotif={(val: any) => { setCountNtf(val); }} /> */} ); }