"use client"; import React, { useMemo } from "react"; import type { MenuItem } from "@/lib/api/menu"; interface Props { menus: MenuItem[]; selectedId: string; } export function MenuOverviewPanel({ menus, selectedId }: Props) { const stats = useMemo(() => { // 선택된 노드가 없으면 전체 기준, 있으면 L1이면 그 하위 전체, L2면 그 하위 자손 const selected = menus.find((m) => String(m.objid ?? m.OBJID) === selectedId); const selectedLev = selected ? Number(selected.lev ?? selected.LEV ?? 1) : 0; const descendants = (rootId: string): MenuItem[] => { const collected: MenuItem[] = []; const visit = (id: string) => { for (const m of menus) { const mid = String(m.objid ?? m.OBJID); const pid = String(m.parent_obj_id ?? m.PARENT_OBJ_ID ?? "0"); if (pid === id) { collected.push(m); visit(mid); } } }; visit(rootId); return collected; }; const scope = selected ? [selected, ...descendants(selectedId)] : menus; const total = scope.length; const active = scope.filter((m) => (m.status ?? m.STATUS ?? "").toString().toLowerCase() === "active").length; const inactive = total - active; const linked = scope.filter((m) => (m.menu_url ?? m.MENU_URL ?? "").trim().length > 0).length; return { total, active, inactive, linked, selectedLev, selectedName: selected ? (selected.menu_name_kor ?? selected.MENU_NAME_KOR ?? "") : "" }; }, [menus, selectedId]); return (
03Overview

{stats.selectedName || "전체 메뉴"} · {stats.total}개 항목

트리에서 L1을 선택하면 해당 카테고리의 하위 전체 통계가 표시됩니다.

전체
{stats.total} items
활성
{stats.active} / {stats.total}
비활성
{stats.inactive} disabled
URL 연결
{stats.linked} linked
L2 메뉴를 클릭하면 Settings 탭으로 자동 전환되어 편집할 수 있습니다.
); }