diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-06-30 08:28:13 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-06-30 08:28:13 +0000 |
| commit | 5b6313f16f508882a0ea67716b7dbaa1c6967f04 (patch) | |
| tree | 3d1d8dafea2f31274ace3fbda08333e889e06d1c /components/layout/MobileMenu.tsx | |
| parent | 3f0fad18483a5c800c79c5e33946d9bb384c10e2 (diff) | |
(대표님) 20250630 16시 - 유저 도메인별 라우터 분리와 보안성검토 대응
Diffstat (limited to 'components/layout/MobileMenu.tsx')
| -rw-r--r-- | components/layout/MobileMenu.tsx | 87 |
1 files changed, 51 insertions, 36 deletions
diff --git a/components/layout/MobileMenu.tsx b/components/layout/MobileMenu.tsx index 2e70aeba..dc02d2e3 100644 --- a/components/layout/MobileMenu.tsx +++ b/components/layout/MobileMenu.tsx @@ -5,29 +5,42 @@ import * as React from "react"; import Link from "next/link"; import { useRouter, usePathname } from "next/navigation"; -import { MenuSection, mainNav, additionalNav, MenuItem, mainNavVendor, additionalNavVendor } from "@/config/menuConfig"; +import { MenuSection, MenuItem } from "@/config/menuConfig"; import { cn } from "@/lib/utils"; import { Drawer, DrawerContent, DrawerTitle, DrawerTrigger } from "@/components/ui/drawer"; import { Button } from "@/components/ui/button"; +import { filterActiveMenus, filterActiveAdditionalMenus } from "@/hooks/use-active-menus"; interface MobileMenuProps { lng: string; onClose: () => void; + activeMenus?: Record<string, boolean>; + domainMain?: MenuSection[]; // 헤더에서 계산된 도메인별 메인 메뉴 + domainAdditional?: MenuItem[]; // 헤더에서 계산된 도메인별 추가 메뉴 } -export function MobileMenu({ lng, onClose }: MobileMenuProps) { +export function MobileMenu({ + lng, + onClose, + activeMenus = {}, + domainMain = [], + domainAdditional = [] +}: MobileMenuProps) { const router = useRouter(); - - + const handleLinkClick = (href: string) => { router.push(href); onClose(); }; - const pathname = usePathname(); - const isPartnerRoute = pathname?.includes("/partners"); - const main = isPartnerRoute ? mainNavVendor : mainNav; - const additional = isPartnerRoute ? additionalNavVendor : additionalNav; + // 활성 메뉴만 필터링 (activeMenus가 빈 객체면 모든 메뉴 표시) + const main = Object.keys(activeMenus).length > 0 + ? filterActiveMenus(domainMain, activeMenus) + : domainMain; + + const additional = Object.keys(activeMenus).length > 0 + ? filterActiveAdditionalMenus(domainAdditional, activeMenus) + : domainAdditional; return ( <Drawer open={true} onOpenChange={onClose}> @@ -36,42 +49,44 @@ export function MobileMenu({ lng, onClose }: MobileMenuProps) { <DrawerTitle /> <DrawerContent className="max-h-[60vh] p-0"> <div className="overflow-auto p-6"> - <nav> <ul className="space-y-4"> - {/* 메인 네비게이션 섹션 */} + {/* 메인 네비게이션 섹션 - 도메인별 활성화된 메뉴만 표시 */} {main.map((section: MenuSection) => ( - <li key={section.title}> - <h3 className="text-md font-medium">{section.title}</h3> - <ul className="mt-2 space-y-2"> - {section.items.map((item: MenuItem) => ( - <li key={item.title}> - <Link - href={`/${lng}${item.href}`} - className="text-indigo-600" - onClick={() => handleLinkClick(item.href)} - > - {item.title} - {item.label && ( - <span className="ml-2 rounded-md bg-[#adfa1d] px-1.5 py-0.5 text-xs text-[#000000]"> - {item.label} - </span> + // 섹션에 아이템이 있는 경우에만 표시 + section.items.length > 0 && ( + <li key={section.title}> + <h3 className="text-md font-medium">{section.title}</h3> + <ul className="mt-2 space-y-2"> + {section.items.map((item: MenuItem) => ( + <li key={item.title}> + <Link + href={`/${lng}${item.href}`} + className="text-indigo-600" + onClick={() => handleLinkClick(item.href)} + > + {item.title} + {item.label && ( + <span className="ml-2 rounded-md bg-[#adfa1d] px-1.5 py-0.5 text-xs text-[#000000]"> + {item.label} + </span> + )} + </Link> + {item.description && ( + <p className="text-xs text-gray-500">{item.description}</p> )} - </Link> - {item.description && ( - <p className="text-xs text-gray-500">{item.description}</p> - )} - </li> - ))} - </ul> - </li> + </li> + ))} + </ul> + </li> + ) ))} - - {/* 추가 네비게이션 항목 */} + + {/* 추가 네비게이션 항목 - 도메인별 활성화된 메뉴만 표시 */} {additional.map((item: MenuItem) => ( <li key={item.title}> <Link - href={item.href} + href={`/${lng}${item.href}`} className="block text-sm text-indigo-600" onClick={() => handleLinkClick(`/${lng}${item.href}`)} > |
