Files
frontend/apps/wr/app/(with-layout)/layout.tsx

57 lines
1.4 KiB
TypeScript

// "use client";
// import Base from "../base";
// export default function RootLayout({
// children,
// }: Readonly<{
// children: React.ReactNode;
// }>) {
// return (
// <Base>
// {children}
// </Base>
// );
// }
"use client";
import { BaseLayout } from "@common/components/ui";
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";
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 changeMenu = (path: MenuItem) => {
setCurrentMenuInfo(path);
getMenuAuthrts(path.menuCd);
if (path.menuKornNm === "하수재이용통계") {
return null;
} else {
router.push(path.urlPath);
}
};
return (
<BaseLayout currentPath={pathname ?? ""} handleMenuClick={changeMenu}>
<PageLayout>
<MainDiv>{children}</MainDiv>
</PageLayout>
</BaseLayout>
);
}