"use client"; import { useEffect, useState, type ComponentType, type ReactNode } from "react"; import { ChartColumnBig, ChevronDown, ChevronUp, PanelsTopLeft, PencilRuler, Search, Settings2, TriangleAlert, Waves, } from "lucide-react"; import { windowPopupDefinitions, type WindowPopupKey, } from "@/features/windowPopup/model/popupDefinitions"; type Props = { onOpenPopup: (popupKey: WindowPopupKey) => Window | null; onOpenInfoSearch: () => void; onToggleGisEdit?: () => void; isGisEditActive?: boolean; isInfoSearchActive?: boolean; initialActiveKey?: WindowPopupKey | null; }; type MenuIconProps = { isActive: boolean; }; const InftwtMenuIcon = ({ isActive }: MenuIconProps) => ( ); const ANALYSIS_POPUP_ITEMS: Array<{ key: WindowPopupKey | "infoSearch"; label: string; icon?: ComponentType<{ className?: string }>; renderIcon?: (props: MenuIconProps) => ReactNode; }> = [ { key: "infoSearch", label: windowPopupDefinitions.mapSearch.title, icon: Search, }, { key: "pipeAnalysisPopup", label: windowPopupDefinitions.pipeAnalysisPopup.title, icon: ChartColumnBig, }, { key: "floodPredictionMapPopup", label: windowPopupDefinitions.floodPredictionMapPopup.title, icon: Waves, }, { key: "agedPipeStatusByCtpvPopup", label: windowPopupDefinitions.agedPipeStatusByCtpvPopup.title, icon: ChartColumnBig, }, { key: "gisEditPopup", label: windowPopupDefinitions.gisEditPopup.title, icon: PencilRuler, }, { key: "gisManagementPopup", label: windowPopupDefinitions.gisManagementPopup.title, icon: Settings2, }, { key: "flowRiskPopup", label: windowPopupDefinitions.flowRiskPopup.title, icon: TriangleAlert, }, { key: "inftwtResultPopup", label: windowPopupDefinitions.inftwtResultPopup.title, renderIcon: InftwtMenuIcon, }, { key: "rdiiResultPopup", label: windowPopupDefinitions.rdiiResultPopup.title, icon: ChartColumnBig, }, ]; export default function AnalysisPopupMenu({ onOpenPopup, onOpenInfoSearch, onToggleGisEdit, isGisEditActive = false, isInfoSearchActive = false, initialActiveKey = null, }: Props) { const [isOpen, setIsOpen] = useState(true); const [activeKey, setActiveKey] = useState< WindowPopupKey | "infoSearch" | null >(initialActiveKey); useEffect(() => { if (!isGisEditActive && activeKey === "gisEditPopup") { setActiveKey(null); } }, [activeKey, isGisEditActive]); useEffect(() => { if (!isInfoSearchActive && activeKey === "infoSearch") { setActiveKey(null); } }, [activeKey, isInfoSearchActive]); useEffect(() => { if (!initialActiveKey) return; setActiveKey((currentKey) => currentKey ?? initialActiveKey); }, [initialActiveKey]); return (
분석도구
{isOpen ? (
{ANALYSIS_POPUP_ITEMS.map((item) => { const Icon = item.icon; const isActive = item.key === "gisEditPopup" ? isGisEditActive : activeKey === item.key; return ( ); })}
) : null}
); }