currentPath 추가

This commit is contained in:
2025-07-26 16:07:19 +09:00
parent 2aba7bb16e
commit 5c7a8df55f
3 changed files with 35 additions and 23 deletions
+10 -4
View File
@@ -3,7 +3,7 @@
import { BaseLayout } from "@common/components";
import type { MenuItem } from "./store/common";
import { useDmStore } from "./store";
import { useRouter } from "next/navigation";
import { usePathname, useRouter } from "next/navigation";
export default function Base({
children,
@@ -13,10 +13,16 @@ export default function Base({
const { getMenuAuth } = useDmStore((state) => state);
const router = useRouter();
const handleClick = (id:MenuItem) =>{
const pathname = usePathname();
const handleClick = (id: MenuItem) => {
getMenuAuth(id.menuCd);
router.push(id.urlPath);
}
};
return <BaseLayout handleMenuClick={handleClick}>{children}</BaseLayout>;
return (
<BaseLayout currentPath={pathname ?? ""} handleMenuClick={handleClick}>
{children}
</BaseLayout>
);
}
+10 -5
View File
@@ -3,7 +3,7 @@
import { BaseLayout } from "@common/components";
import type { MenuItem } from "./store/common";
import { useFoStore } from "./store";
import { useRouter } from "next/navigation";
import { usePathname, useRouter } from "next/navigation";
export default function Base({
children,
@@ -11,12 +11,17 @@ export default function Base({
children: React.ReactNode;
}>) {
const { getMenuAuth } = useFoStore((state) => state);
const pathname = usePathname();
const router = useRouter();
const handleClick = (id:MenuItem) =>{
const handleClick = (id: MenuItem) => {
getMenuAuth(id.menuCd);
router.push(id.urlPath);
}
};
return <BaseLayout handleMenuClick={handleClick}>{children}</BaseLayout>;
return (
<BaseLayout currentPath={pathname ?? ""} handleMenuClick={handleClick}>
{children}
</BaseLayout>
);
}
+15 -14
View File
@@ -1,24 +1,25 @@
"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 { useRouter } from "next/navigation"
"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";
export default function Base({
children,
}: Readonly<{
children: React.ReactNode
children: React.ReactNode;
}>) {
const { getMenuAuthrts } = useWrStore((state) => state)
const router = useRouter()
const { getMenuAuthrts } = useWrStore((state) => state);
const router = useRouter();
const pathname = usePathname();
const changeMenu = (path: MenuItem) => {
getMenuAuthrts(path.menuCd)
router.push(path.urlPath)
}
getMenuAuthrts(path.menuCd);
router.push(path.urlPath);
};
return (
<BaseLayout handleMenuClick={changeMenu}>
<BaseLayout currentPath={pathname ?? ""} handleMenuClick={changeMenu}>
<MainDiv>{children}</MainDiv>
</BaseLayout>
)
);
}