"use client"; import { useMemo, useState } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { ChevronDown, Moon, Sun, ChevronRight, Plus } from "lucide-react"; import { cn } from "@/lib/utils"; import { useColorMode } from "@/components/providers/ColorModeProvider"; import { Button } from "@/components/ds"; import { OWNER_NAV } from "@/modules/beauty/constants/portals"; function isActive(pathname: string, href: string) { const base = href.split("?")[0]; if (base === "/beauty") return pathname === "/beauty"; return pathname === base || pathname.startsWith(`${base}/`); } /** @deprecated Use BeautyPortalShell with portalId="owner" */ export function BeautyBusinessShell({ children }: { children: React.ReactNode }) { const pathname = usePathname(); const { mode, toggle } = useColorMode(); const [openGroups, setOpenGroups] = useState>({}); const autoOpen = useMemo(() => { const map: Record = {}; for (const g of OWNER_NAV) { if (g.href && isActive(pathname, g.href)) map[g.id] = true; if (g.items?.some((i) => isActive(pathname, i.href))) map[g.id] = true; } return map; }, [pathname]); const expanded = { ...autoOpen, ...openGroups }; const toggleGroup = (id: string) => setOpenGroups((prev) => ({ ...prev, [id]: !(expanded[id] ?? false) })); return (
{OWNER_NAV.flatMap((g) => g.href ? [{ href: g.href, label: g.label }] : (g.items ?? []).slice(0, 1).map((i) => ({ href: i.href, label: g.label })) ).map((item) => ( {item.label} ))}
{children}
{[ { href: "/beauty/organizations", label: "سازمان" }, { href: "/beauty/appointments", label: "نوبت" }, { href: "/beauty/catalog/services", label: "خدمت" }, { href: "/beauty/customers", label: "مشتری" }, { href: "/beauty", label: "داشبورد" }, ].map((item) => ( {item.label} ))}
); }