'use client' import { VerticalTable } from "@/components/verticalTable"; import { Button, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@common/components/ui"; import { use, useEffect, useState } from "react"; import { SwtrmtFcltCol } from "./table"; import { useGisContext } from "@common/business_components/ui/map/Gis"; const inputColumn = [ { id: "title", title: "설치주제", type: "select", options: ["BTL", "재정사업"] }, { id: "guyeok", title: "처리구역", type: "select", options: ["구역1", "구역2"] }, { id: "basu", title: "배수구역", type: "input" }, { id: "bungu", title: "배수분구", type: "input" }, { id: "wltjs", title: "지선/간선", type: "select", options: ["지선", "간선"] }, { id: "flow", title: "흐름방식", type: "select", options: ["자연유하", "압송"] }, { id: "place", title: "매설위치", type: "select", options: ["도로", "하상"] }, ]; // TODO: const FeatureClickEventPopup = ({ onClose, featureData }: { onClose: () => void, featureData: any }) => { const { gisMap } = useGisContext() as unknown as { checkedLayerIds: React.MutableRefObject; treeData: { lyrSn: number }[] | null; gisCore: any; gisMap: any; }; const featureProperties = featureData.getProperties(); // 피처의 속성 가져오기 const [layerNm, setLayerNm] = useState(""); // 레이어 이름 상태 // 피쳐데이터의 현재 레이어 이름 가져오는 함수 const getSelectedLayers = () => { const layers = gisMap.getLayers().getArray(); // gisMap에서 모든 레이어 가져오기 let featureLayer: { get: (key: string) => any } = { get: (key: string) => null }; // 피처가 속한 레이어를 찾기 위한 변수 layers.forEach((layer: any) => { const source = layer.getSource(); if (source && source.hasFeature && source.hasFeature(featureData)) { featureLayer = layer; // 피처가 속한 레이어 찾기 } }); return featureLayer.get('lyrNm'); // 레이어 이름 출력 }; const [repairData, setRepairData] = useState([ { year: "2025", type: "개대체" }, { year: "2025", type: "보수" }, ]); const [cleaningData, setCleaningData] = useState([ { year: "2025", type: "청소" }, { year: "2025", type: "준설" }, ]); const [inspectionData, setInspectionData] = useState([ { year: "2025", type: "관로기술진단" }, { year: "2025", type: "관로기술진단" }, ]); const handleInputChange = (section: string, index: number, field: string, value: string) => { const updateData = (data: { year: string; type: string }[], setData: React.Dispatch>) => { const updated = [...data]; if (updated[index]) { updated[index][field as keyof typeof updated[number]] = value; } setData(updated); }; if (section === "repair") { updateData(repairData, setRepairData); } else if (section === "cleaning") { updateData(cleaningData, setCleaningData); } else if (section === "inspection") { updateData(inspectionData, setInspectionData); } }; function transformFeatureDataToArray(featureProperties: any, keys: string[]) { // 필요한 키만 추출하여 새로운 객체 생성 const transformedData = keys.reduce((acc, key) => { acc[key] = featureProperties[key] !== undefined ? featureProperties[key] : "N/A"; // 값이 없으면 "N/A"로 처리 return acc; }, {} as Record); // 배열로 감싸서 반환 return [transformedData]; } const keys = SwtrmtFcltCol.map((column) => column.id); const transformedFeatureData = transformFeatureDataToArray(featureProperties, keys); useEffect(() => { setLayerNm(getSelectedLayers()) }, [featureProperties]); const renderSection = (title: string, data: { year: string; type: string }[], sectionKey: string) => (
{/* 섹션 제목 */}

{title}

{/* 테이블 */}
년도 구분 {data.map((row, index) => ( handleInputChange(sectionKey, index, "year", e.target.value)} className="w-full text-xl border-radius-0 px-3 py-2 text-base text-center leading-normal" /> {row.type} ))}
); return ( ) } export default FeatureClickEventPopup;