44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
"use client";
|
|
import { BaseLayout } from "@common/components/ui";
|
|
import { useQueryClient } from "@tanstack/react-query";
|
|
import { useWrStore } from "../store";
|
|
import { MainDiv } from "@common/business_components/ui";
|
|
import type { MenuItem } from "../store/common/type/menu";
|
|
import { usePathname, useRouter } from "next/navigation";
|
|
import { useMenuStore } from "@/src/shared/lib";
|
|
import { PageLayout } from "@/src/shared/ui/page-layout";
|
|
import { authService } from "@/src/entities/auth";
|
|
|
|
export default function RootLayout({
|
|
children,
|
|
}: Readonly<{
|
|
children: React.ReactNode;
|
|
}>) {
|
|
const { getMenuAuthrts } = useWrStore((state) => state);
|
|
const setCurrentMenuInfo = useMenuStore((state) => state.setCurrentMenuInfo);
|
|
const router = useRouter();
|
|
const pathname = usePathname();
|
|
const queryClient = useQueryClient();
|
|
|
|
const changeMenu = (path: MenuItem) => {
|
|
setCurrentMenuInfo(path);
|
|
getMenuAuthrts(path.menuCd);
|
|
if (path.menuKornNm === "하수재이용통계") {
|
|
return null;
|
|
} else {
|
|
router.push(path.urlPath);
|
|
}
|
|
};
|
|
return (
|
|
<BaseLayout queryClient={queryClient}
|
|
authService={authService}
|
|
currentPath={pathname ?? ""}
|
|
handleMenuClick={changeMenu}>
|
|
<PageLayout>
|
|
<MainDiv>{children}</MainDiv>
|
|
</PageLayout>
|
|
</BaseLayout>
|
|
);
|
|
}
|
|
|