From 5b6313f16f508882a0ea67716b7dbaa1c6967f04 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 30 Jun 2025 08:28:13 +0000
Subject: (대표님) 20250630 16시 - 유저 도메인별 라우터 분리와 보안성검토 대응
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 components/layout/GroupedMenuRender.tsx | 53 ++++++++++++++++++++++-----------
 1 file changed, 36 insertions(+), 17 deletions(-)

(limited to 'components/layout/GroupedMenuRender.tsx')

diff --git a/components/layout/GroupedMenuRender.tsx b/components/layout/GroupedMenuRender.tsx
index e2a5a225..9006c85d 100644
--- a/components/layout/GroupedMenuRender.tsx
+++ b/components/layout/GroupedMenuRender.tsx
@@ -4,6 +4,7 @@ import { NavigationMenuLink } from "@/components/ui/navigation-menu";
 import { cn } from "@/lib/utils";
 import * as LucideIcons from "lucide-react";
 import { MenuItem } from '@/config/menuConfig';
+import { filterActiveAdditionalMenus } from "@/hooks/use-active-menus";
 
 type GroupedMenuItems = {
   [key: string]: MenuItem[];
@@ -12,9 +13,15 @@ type GroupedMenuItems = {
 interface GroupedMenuRendererProps {
   items: MenuItem[];
   lng: string;
+  activeMenus?: Record<string, boolean>; // 활성 메뉴 상태 추가
 }
 
-const GroupedMenuRenderer = ({ items, lng }: GroupedMenuRendererProps) => {
+const GroupedMenuRenderer = ({ items, lng, activeMenus = {} }: GroupedMenuRendererProps) => {
+  // 활성 메뉴만 필터링 (activeMenus가 빈 객체면 모든 메뉴 표시)
+  const filteredItems = Object.keys(activeMenus).length > 0 
+    ? filterActiveAdditionalMenus(items, activeMenus)
+    : items;
+
   // 그룹별로 아이템 분류
   const groupItems = (items: MenuItem[]): GroupedMenuItems => {
     return items.reduce((groups, item) => {
@@ -27,32 +34,44 @@ const GroupedMenuRenderer = ({ items, lng }: GroupedMenuRendererProps) => {
     }, {} as GroupedMenuItems);
   };
 
-  const groupedItems = groupItems(items);
+  const groupedItems = groupItems(filteredItems);
   const groups = Object.keys(groupedItems);
 
+  // 활성 메뉴가 없으면 아무것도 렌더링하지 않음
+  if (filteredItems.length === 0) {
+    return (
+      <div className="p-4 w-[600px]">
+        <p className="text-sm text-muted-foreground text-center py-8">
+          사용 가능한 메뉴가 없습니다.
+        </p>
+      </div>
+    );
+  }
+
   return (
     <div className="p-4 w-[600px]">
-      {groups.map((groupName, index) => (
-        <div key={groupName} className={cn("mb-4", index < groups.length - 1 && "pb-2 border-b border-border/30")}>
-          {groupName !== 'default' && (
-            <h3 className="text-sm font-semibold mb-2 text-primary">{groupName}</h3>
-          )}
-          <div className="grid grid-cols-2 gap-3">
-            {groupedItems[groupName].map((item) => (
-              <MenuListItem key={item.title} item={item} lng={lng} />
-            ))}
+      {groups.map((groupName, index) => {
+        // 빈 그룹은 건너뛰기
+        if (groupedItems[groupName].length === 0) return null;
+        
+        return (
+          <div key={groupName} className={cn("mb-4", index < groups.length - 1 && "pb-2 border-b border-border/30")}>
+            {groupName !== 'default' && (
+              <h3 className="text-sm font-semibold mb-2 text-primary">{groupName}</h3>
+            )}
+            <div className="grid grid-cols-2 gap-3">
+              {groupedItems[groupName].map((item) => (
+                <MenuListItem key={item.title} item={item} lng={lng} />
+              ))}
+            </div>
           </div>
-        </div>
-      ))}
+        );
+      })}
     </div>
   );
 };
 
 const MenuListItem = ({ item, lng }: { item: MenuItem; lng: string }) => {
-
-  
- 
-  
   return (
     <NavigationMenuLink asChild>
       <Link
-- 
cgit v1.2.3

