"use client"; import { headMakeColSpan } from "@/app/ruseFcltMng/fcltReg/rainReg/page"; import { useWrStore } from "@/app/store"; import { selectClass, type customRainBdst, } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { ScrollArea, SelectBox, UiTable } from "@common/business_components"; import { Button, Input, Label } from "@common/components"; import { useEffect, useState } from "react"; import { RainRegForm } from "../../form/fcltReg/rainReg/rainRegForm"; import { type selectArray } from "@/app/store/common/code"; import { getCity, tableData } from "@/components/lib/func/commom"; import type { customRswtBdst } from "@/app/store/ruseFcltMng/fcltReg/rswtReg"; import { HtdflRegForm } from "../../form/fcltReg/htdflReg/htdflRegForm"; import type { customHtdflBdst } from "@/app/store/ruseFcltMng/fcltReg/htdflReg"; import { RswtrRegForm } from "../../form/fcltReg/rswtrReg/RswtrRegForm"; export type objSearchType = { sgg: string|number; city: string|number; }; //RNB(빗물), RST(중수도), HTB(온배수) type MoType = 'RNB' | 'RST' | 'HTB'; // 여기에 'htdf' 추가 type BdstTypeMap = { RNB: customRainBdst; RST: customRswtBdst; HTB: customRswtBdst; // 해야해// 아직 아노딤 }; interface BdstRegProps { moType: T; } export function BdstReg({ moType }: BdstRegProps) { const { rain, code, bdst,findBdst } = useWrStore((state) => { return state; }); const [bdstTable, setbdstTable] = useState(); const [rainBdstForm, setRainBdstForm] = useState({} as BdstTypeMap[T]); const [searchTxt, setSearchTxt] = useState() const [selectSgg, setSelectSgg] = useState() const [objSearch, setObjSearch] = useState({sgg:"",city:""}); const getSelCity = (val: string | number) => { const cityValue = String(val); // Ensure val is treated as a string const data = getCity(cityValue, code.sggCd); setSelectSgg(data); setObjSearch({ city: cityValue, sgg: '' }); }; const getSgg = (val: string | number) => { console.log(val); setObjSearch({...objSearch,sgg: String(val)}) }; const searchBdst=(searchTxt: string | undefined)=>{ let data =objSearch.city; if(objSearch.city==="" ){ data = String(code.cityCd[0]?.val) } if(objSearch.sgg !=="" ){ data = objSearch.sgg } //RNB(빗물), RST(중수도), HTB(온배수) findBdst(String(data), searchTxt || "",moType ) } useEffect(() => { if (code.sggCd.length > 0) { setbdstTable( tableData(bdst.bdstBase, { code })); } }, [ bdst]); const tableClick: (val: number | undefined , headId:string) => void = (val ,headId) => { if(val!==undefined && bdst?.bdstBase.length>0){ const data:BdstTypeMap[T] =bdst?.bdstBase[val] if (data) { setRainBdstForm(data); } } } useEffect(()=>{ setbdstTable([]) // 초기화 작업 },[]) const nodeList = headMakeColSpan(bdst.moUpHeadList); return ( <>
{""} {" "} setSearchTxt(e.target.value)}/>
(tableClick(idx, headId||"" ))} > {nodeList}
{ moType === 'RNB'? :moType==='RST' ? : }
); }