Files
frontend/apps/sn/app/map/components/common/index.ts
T

45 lines
1.4 KiB
TypeScript

import smh from "../smh";
import Ssc from "../Ssc";
import SwtrmtFclt from "../SwtrmtFclt";
// 레이어 이름과 컴포넌트를 매핑
const layerContentMap: { [key: string]: { component: React.FC<any>; props?: any; } } = {
// TODO: gis데이터 추가되면 추가 작업 필요
"하수처리시설": {
component: SwtrmtFclt,
},
"하수처리구역": { component: Ssc, },
"중점우수토실":{component: Ssc,},
"하수관로":{component: SwtrmtFclt,},
"하수맨홀":{component: smh,},
};
// 동적 컴포넌트 반환 함수
export const getLayerContentComponent = (layerNm: string): React.FC => {
const component = layerContentMap[layerNm];
if (!component) {
throw new Error(`Component not found for layer name: ${layerNm}`);
}
return component.component;
};
// 사용자 입력 필드 (보수 및 갱신, 청소 및 준설, 점검 및 진단)
export const handleInputChange = (section: string,
index: number,
field: string,
value: string,
dataMap: {
[key: string]: {
data: { year: string; type: string }[];
setData: React.Dispatch<React.SetStateAction<{ year: string; type: string }[]>>;
};
}
) => {
const target = dataMap[section];
if (!target) return;
const updated = [...target.data];
if (updated[index]) {
updated[index][field as keyof typeof updated[number]] = value;
}
target.setData(updated);
};