'use client' import colors from "@/con/colors"; import { ActionIcon, AppShell, AppShellHeader, AppShellMain, AppShellNavbar, Box, Burger, Flex, Group, Image, NavLink, ScrollArea, Text } from "@mantine/core"; import { useDisclosure } from "@mantine/hooks"; import { IconChevronLeft, IconChevronRight, IconDoorExit } from "@tabler/icons-react"; import _ from 'lodash'; import Link from "next/link"; import { useRouter, useSelectedLayoutSegments } from "next/navigation"; import { navBar } from "./_com/list_PageAdmin"; export default function Layout({ children }: { children: React.ReactNode }) { const [opened, { toggle }] = useDisclosure(); const [desktopOpened, { toggle: toggleDesktop }] = useDisclosure(true); const router = useRouter() // Normalisasi semua segmen jadi lowercase const segments = useSelectedLayoutSegments().map(s => _.lowerCase(s)); return ( Dashboard Admin {!desktopOpened && ( )} { router.push("/darmasaba") }} color={colors["blue-button"]} radius={'xl'}> {navBar.map((v, k) => { const isParentActive = segments.includes(_.lowerCase(v.name)); return ( {v.name} } > {v.children.map((child, key) => { const isChildActive = segments.includes(_.lowerCase(child.name)); return ( {child.name} } /> ); })} ); })} {children} ); }