diff --git a/apps/common/features/app/(with-base-layout)/(contents)/layout.tsx b/apps/common/features/app/(with-base-layout)/(contents)/layout.tsx new file mode 100644 index 000000000..86007388a --- /dev/null +++ b/apps/common/features/app/(with-base-layout)/(contents)/layout.tsx @@ -0,0 +1,27 @@ +"use client"; + +import { useQuery } from "@tanstack/react-query"; +import { MenuApi } from "@/entities/menu"; +import { getCookie } from "@/shared/lib"; +import { ENDPOINT } from "@/shared/config"; +import { PageLayout } from "@/shared/ui/page-layout"; + +export default function ContentsLayout({ + children, +}: { + children: React.ReactNode; +}) { + const menuCd = getCookie("menu-code-key"); + const { data } = useQuery({ + queryKey: [ENDPOINT.CMS_SERVICE.MENUS, menuCd], + queryFn: () => MenuApi.getMenuInfo(menuCd!), + enabled: !!menuCd, + }); + const menuPaths = data?.menuPath?.split(">").map((path) => path.trim()); + + return ( + + {children} + + ); +} diff --git a/apps/common/features/app/(with-base-layout)/(post)/layout.tsx b/apps/common/features/app/(with-base-layout)/(post)/layout.tsx index b46f59fa5..023b912cb 100644 --- a/apps/common/features/app/(with-base-layout)/(post)/layout.tsx +++ b/apps/common/features/app/(with-base-layout)/(post)/layout.tsx @@ -1,3 +1,5 @@ +"use client"; + import { MenuApi } from "@/entities/menu"; import { ENDPOINT } from "@/shared/config"; import { getCookie, useMenuStore } from "@/shared/lib"; diff --git a/apps/common/features/app/(with-base-layout)/layout.tsx b/apps/common/features/app/(with-base-layout)/layout.tsx index d357094ae..5bbd7d024 100644 --- a/apps/common/features/app/(with-base-layout)/layout.tsx +++ b/apps/common/features/app/(with-base-layout)/layout.tsx @@ -1,12 +1,10 @@ "use client"; import { usePathname, useRouter } from "next/navigation"; -import { useQuery, useQueryClient } from "@tanstack/react-query"; +import { useQueryClient } from "@tanstack/react-query"; import { BaseLayout } from "@common/components"; -import { MenuApi, type MenuRole } from "@/entities/menu"; -import { ENDPOINT } from "@/shared/config"; -import { getCookie, useMenuStore } from "@/shared/lib"; -import { PageLayout } from "@/shared/ui/page-layout"; +import type { MenuRole } from "@/entities/menu"; +import { useMenuStore } from "@/shared/lib"; export default function WithBaseLayout({ children, @@ -16,16 +14,6 @@ export default function WithBaseLayout({ const router = useRouter(); const pathname = usePathname(); const queryClient = useQueryClient(); - const bbsInfo = useMenuStore((state) => state.bbsInfo); - - const menuCd = getCookie("menu-code-key"); - const { data } = useQuery({ - queryKey: [ENDPOINT.CMS_SERVICE.MENUS, menuCd], - queryFn: () => MenuApi.getMenuInfo(menuCd!), - enabled: !!menuCd, - }); - - const menuPaths = data?.menuPath?.split(">").map((path) => path.trim()); const setCurrentMenuInfo = useMenuStore((state) => state.setCurrentMenuInfo); @@ -40,9 +28,7 @@ export default function WithBaseLayout({ currentPath={pathname ?? ""} handleMenuClick={handleMenuClick} > - - {children} - + {children} ); }