36 lines
922 B
TypeScript
36 lines
922 B
TypeScript
"use client";
|
|
|
|
import { usePathname, useRouter } from "next/navigation";
|
|
import { useQueryClient } from "@tanstack/react-query";
|
|
import type { MenuItem } from "@common/components/api";
|
|
import { BaseLayout } from "@common/components/ui";
|
|
import { useMenuStore } from "@/shared/lib";
|
|
import { PageLayout } from "@/shared/ui/page-layout";
|
|
|
|
export default function WithBaseLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
const router = useRouter();
|
|
const pathname = usePathname();
|
|
const queryClient = useQueryClient();
|
|
|
|
const { setCurrentMenuInfo } = useMenuStore((state) => state);
|
|
|
|
const handleMenuClick = (item: MenuItem) => {
|
|
setCurrentMenuInfo(item);
|
|
router.push(item.urlPath);
|
|
};
|
|
|
|
return (
|
|
<BaseLayout
|
|
queryClient={queryClient}
|
|
currentPath={pathname ?? ""}
|
|
handleMenuClick={handleMenuClick}
|
|
>
|
|
<PageLayout>{children}</PageLayout>
|
|
</BaseLayout>
|
|
);
|
|
}
|