로그인 사용자 건축물 등록 시도코드 적용/ 하수처리장 지도PopUp data 오류 슈ㅜ정/지도점검 오류 수정
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
} from "@common/business_components";
|
||||
import { Button, Input, Label } from "@common/components";
|
||||
import { useEffect, useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
export type objSearchType = {
|
||||
sgg: string | number;
|
||||
@@ -68,7 +69,12 @@ export function BdstReg<T extends MoType>({
|
||||
data = objSearch.sgg;
|
||||
}
|
||||
//RNB(빗물), RST(중수도), HTB(온배수)
|
||||
findBdst(String(data), searchTxt || "", moType);
|
||||
if(data){
|
||||
|
||||
findBdst(String(data), searchTxt || "", moType);
|
||||
}else{
|
||||
toast.error("시도 또는 시군구를 선택하여 주십시오.");
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -88,33 +94,41 @@ export function BdstReg<T extends MoType>({
|
||||
}, [bdst]);
|
||||
|
||||
useEffect(() => {
|
||||
let city = [] as SelectDataType[];
|
||||
if (laeSeCd.length === 2 && code.cityCd.length > 0) {
|
||||
const city = code.cityCd.filter((item) => item.val === laeSeCd);
|
||||
const sgg = code.sggCd.filter((item) => item.val.slice(0, 2) === laeSeCd);
|
||||
sgg.unshift({ text: "전체", val: "0" });
|
||||
city = code.cityCd.filter((item) => item.val === laeSeCd);
|
||||
setUserCityCd(city); // Fix: Ensure city is of type SelectDataType[]
|
||||
setObjSearch({ ...objSearch, city: String(city[0]?.val) });
|
||||
setUserSggCd(sgg);
|
||||
} else if (
|
||||
laeSeCd.length === 5 &&
|
||||
code.cityCd.length > 0 &&
|
||||
code.sggCd.length > 0
|
||||
) {
|
||||
const city = code.cityCd.filter(
|
||||
(item) => item.val === laeSeCd.slice(0, 2)
|
||||
);
|
||||
city = code.cityCd.filter((item) => item.val === laeSeCd.slice(0, 2));
|
||||
setUserCityCd(city);
|
||||
const sgg = code.sggCd.filter((item) => item.val === laeSeCd);
|
||||
setUserSggCd(sgg);
|
||||
setObjSearch({ city: String(city[0]?.val), sgg: String(sgg[0]?.val) });
|
||||
} else if (
|
||||
laeSeCd === "0" &&
|
||||
code.cityCd.length > 0 &&
|
||||
code.sggCd.length > 0
|
||||
) {
|
||||
setUserCityCd(code.cityCd);
|
||||
}
|
||||
if (city.length > 0)
|
||||
setObjSearch({ ...objSearch, city: Number(city[0]?.val) ?? "0" });
|
||||
}, [laeSeCd, code.cityCd, code.sggCd]);
|
||||
|
||||
useEffect(() => {
|
||||
const city = String(objSearch.city);
|
||||
if (city === "0") {
|
||||
setUserSggCd([{ text: "전체", val: "0" }]);
|
||||
setObjSearch({ ...objSearch, sgg: "0" });
|
||||
} else if (city.length === 2) {
|
||||
const sgg = code.sggCd.filter((item) => item.val.slice(0, 2) === city);
|
||||
//sgg.unshift({ text: "전체", val: "0" });
|
||||
setUserSggCd(sgg);
|
||||
setObjSearch({ ...objSearch, sgg: Number(sgg[0]?.val) });
|
||||
}
|
||||
}, [objSearch.city]);
|
||||
|
||||
const tableClick: (val: number | undefined, headId: string) => void = (
|
||||
val
|
||||
) => {
|
||||
@@ -136,21 +150,23 @@ export function BdstReg<T extends MoType>({
|
||||
className="col-span-3 h-full"
|
||||
label={"시도"}
|
||||
selectClass={selectClass}
|
||||
key={`city-${String(objSearch.city)}`}
|
||||
selectArray={useCityCd}
|
||||
onSelectValue={(val) => {
|
||||
setObjSearch({ ...objSearch, city: String(val) });
|
||||
setObjSearch({ ...objSearch, city: Number(val) });
|
||||
}}
|
||||
value={objSearch.city || useCityCd[0]?.val}
|
||||
value={objSearch.city ?? useCityCd[0]?.val}
|
||||
></SelectBox>
|
||||
<SelectBox
|
||||
className="col-span-3 h-full"
|
||||
label={"시군구"}
|
||||
key={`sgg-${String(objSearch.sgg)}`}
|
||||
selectClass={selectClass}
|
||||
selectArray={useSggCd || []}
|
||||
onSelectValue={(val) => {
|
||||
if (val) setObjSearch({ ...objSearch, sgg: String(val) });
|
||||
if (val) setObjSearch({ ...objSearch, sgg: Number(val) });
|
||||
}}
|
||||
value={objSearch.sgg || useSggCd[0]?.val}
|
||||
value={objSearch.sgg ?? useSggCd[0]?.val}
|
||||
>
|
||||
{" "}
|
||||
</SelectBox>
|
||||
|
||||
Reference in New Issue
Block a user