"use client"; import { useWrStore } from "@/app/store"; import type { customHtdflBdst } from "@/app/store/ruseFcltMng/fcltReg/htdflReg"; import { selectClass, type customRainBdst, } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import type { customRswtBdst } from "@/app/store/ruseFcltMng/fcltReg/rswtReg"; import { tableData } from "@/components/lib/func/commom"; import HtdflRegForm from "@/components/ui/form/fcltReg/htdflReg/htdflRegForm"; import RainRegForm from "@/components/ui/form/fcltReg/rainReg/rainRegForm"; import RswtrRegForm from "@/components/ui/form/fcltReg/rswtrReg/rswtrRegForm"; import { ScrollArea, SelectBox, UiTable, type SelectDataType, } from "@common/business_components"; import { Button, Input, Label } from "@common/components"; import { useEffect, useState } from "react"; 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; isModal: boolean; setIsModal?: (open: boolean) => void; } export function BdstReg({ moType, setIsModal, isModal, }: BdstRegProps) { const { code, bdst, findBdst } = useWrStore((state) => { return state; }); const { userSiSggCd } = code; const [bdstTable, setbdstTable] = useState(); const [rainBdstForm, setRainBdstForm] = useState( {} as BdstTypeMap[T] ); const [searchTxt, setSearchTxt] = useState(); const [objSearch, setObjSearch] = useState({ sgg: "", city: "", }); const [useCityCd, setUserCityCd] = useState([]); const [useSggCd, setUserSggCd] = useState([]); const searchBdst = (searchTxt: string | undefined) => { let data = objSearch.city; if (objSearch.sgg !== "" && objSearch.sgg !== "0") { data = objSearch.sgg; } //RNB(빗물), RST(중수도), HTB(온배수) findBdst(String(data), searchTxt || "", moType); }; useEffect(() => { if (code.sggCd.length > 0) { const bdstData = bdst.bdstBase.map((bdst) => { const archArea = bdst?.archArea.split(".")[0] !== "-1" ? bdst?.archArea.split(".")[0] : "확인불가"; return { ...bdst, archArea: archArea, }; }); setbdstTable(tableData(bdstData, { code })); } }, [bdst]); useEffect(() => { if (userSiSggCd.length === 2 && code.cityCd.length > 0) { const city = code.cityCd.filter((item) => item.val === userSiSggCd); const sgg = code.sggCd.filter( (item) => item.val.slice(0, 2) === userSiSggCd ); sgg.unshift({ text: "전체", val: "0" }); setUserCityCd(city); // Fix: Ensure city is of type SelectDataType[] setObjSearch({ ...objSearch, city: String(city[0]?.val) }); setUserSggCd(sgg); } else if ( userSiSggCd.length === 5 && code.cityCd.length > 0 && code.sggCd.length > 0 ) { const city = code.cityCd.filter( (item) => item.val === userSiSggCd.slice(0, 2) ); setUserCityCd(city); const sgg = code.sggCd.filter((item) => item.val === userSiSggCd); setUserSggCd(sgg); setObjSearch({ city: String(city[0]?.val), sgg: String(sgg[0]?.val) }); } }, [userSiSggCd, code.cityCd, code.sggCd]); const tableClick: (val: number | undefined, headId: string) => void = ( val ) => { if (val !== undefined && bdst?.bdstBase.length > 0) { const data: BdstTypeMap[T] = bdst?.bdstBase[val]; if (data) { setRainBdstForm(data); } } }; useEffect(() => { setbdstTable([]); // 초기화 작업 }, []); return ( <>
{ setObjSearch({ ...objSearch, city: String(val) }); }} value={objSearch.city || useCityCd[0]?.val} > { if (val) setObjSearch({ ...objSearch, sgg: String(val) }); }} value={objSearch.sgg || useSggCd[0]?.val} > {" "} setSearchTxt(e.target.value)} />

건축물 목록 (유의 사항: 신규등록하려는 건축물이 목록에 없을 경우 하단 건축물 정보에 추가하여 주시기 바랍니다.)

tableClick(idx, headId || "")} onPageChange={function (page: number): void { console.log("page ", page); throw new Error("Function not implemented."); }} >
{/* */}
{moType === "RNB" ? ( ) : moType === "RST" ? ( { if (setIsModal && open) { setIsModal(open); } }} > ) : ( { if (setIsModal && open) { setIsModal(open); } }} > )}
{/*
*/}
); }