From ef2f4f7b9e46fab541e47e678d8157f5f34506b2 Mon Sep 17 00:00:00 2001 From: bicochan Date: Fri, 4 Jul 2025 10:12:47 +0900 Subject: [PATCH] =?UTF-8?q?[common/features]=20refactor:=20=EA=B2=8C?= =?UTF-8?q?=EC=8B=9C=ED=8C=90=EA=B3=BC=20=EC=BD=98=ED=85=90=EC=B8=A0=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=A0=88=EC=9D=B4=EC=95=84?= =?UTF-8?q?=EC=9B=83=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../(with-base-layout)/(contents)/layout.tsx | 27 +++++++++++++++++++ .../app/(with-base-layout)/(post)/layout.tsx | 2 ++ .../app/(with-base-layout)/layout.tsx | 22 +++------------ 3 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 apps/common/features/app/(with-base-layout)/(contents)/layout.tsx 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} ); }