"use client"; import { useEffect } from "react"; import { usePathname } from "next/navigation"; import { SITE_ID } from "@/shared/config"; import { useMenuStore } from "@/shared/lib"; import { MenuApi } from "../api/menu-service"; import { getCurrentMenu } from "./utils"; const MenuWrapper = ({ children }: { children: React.ReactNode }) => { const pathname = usePathname(); const { setCurrentMenuInfo } = useMenuStore((state) => state); useEffect(() => { (async () => { const menuRoles = await MenuApi.getMenuRoles(SITE_ID); if (!menuRoles) return; const currentMenu = getCurrentMenu(menuRoles, pathname ?? ""); if (!currentMenu) return; setCurrentMenuInfo(currentMenu); })(); }, []); return <>{children}; }; export { MenuWrapper };