로그인 사용자 건축물 등록 시도코드 적용/ 하수처리장 지도PopUp data 오류 슈ㅜ정/지도점검 오류 수정
This commit is contained in:
@@ -22,12 +22,10 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
|
||||
const [useSggCd, setUserSggCd] = useState<SelectDataType[]>([]);
|
||||
|
||||
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[]
|
||||
setUserSggCd(sgg);
|
||||
if (city[0]?.val) {
|
||||
// 여기 중요
|
||||
queueMicrotask(() => {
|
||||
@@ -43,15 +41,21 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
|
||||
code.cityCd.length > 0 &&
|
||||
code.sggCd.length > 0
|
||||
) {
|
||||
const city = code.cityCd.filter(
|
||||
(item) => item.val === laeSeCd.slice(0, 2)
|
||||
);
|
||||
const sgg = code.sggCd.filter((item) => item.val === laeSeCd);
|
||||
setUserSggCd(sgg);
|
||||
city = code.cityCd.filter((item) => item.val === laeSeCd.slice(0, 2));
|
||||
setUserCityCd(city);
|
||||
form.setValue("ctpvCd", Number(city[0]?.val));
|
||||
form.setValue("sggCd", Number(sgg[0]?.val));
|
||||
} else if (
|
||||
laeSeCd === "0" &&
|
||||
code.cityCd.length > 0 &&
|
||||
code.sggCd.length > 0
|
||||
) {
|
||||
setUserCityCd(code.cityCd);
|
||||
}
|
||||
if (city.length > 0)
|
||||
form.setValue("ctpvCd", Number(city[0]?.val), {
|
||||
shouldDirty: true,
|
||||
shouldTouch: true,
|
||||
shouldValidate: true,
|
||||
});
|
||||
}, [form, laeSeCd, code.cityCd, code.sggCd]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -70,11 +74,34 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
|
||||
const userCtpvCd = form.watch("ctpvCd");
|
||||
const userSggCd = form.watch("sggCd");
|
||||
|
||||
useEffect(() => {
|
||||
const city = String(userCtpvCd);
|
||||
|
||||
if (city && city === "0") {
|
||||
setUserSggCd([{ text: "전체", val: "0" }]);
|
||||
|
||||
form.setValue("sggCd", 0, {
|
||||
shouldDirty: true,
|
||||
shouldTouch: true,
|
||||
shouldValidate: true,
|
||||
});
|
||||
} else if (city && city.length === 2) {
|
||||
const sgg = code.sggCd.filter((item) => item.val.slice(0, 2) === city);
|
||||
setUserSggCd(sgg);
|
||||
form.setValue("sggCd", Number(sgg[0]?.val), {
|
||||
shouldDirty: true,
|
||||
shouldTouch: true,
|
||||
shouldValidate: true,
|
||||
});
|
||||
}
|
||||
}, [userCtpvCd]);
|
||||
|
||||
useEffect(() => {
|
||||
const strCtpvCd = String(userCtpvCd);
|
||||
|
||||
if (strCtpvCd && strCtpvCd !== "0") {
|
||||
const city = returnCodeText(strCtpvCd, "cityCd");
|
||||
|
||||
form?.setValue("daddr", city);
|
||||
} else if (strCtpvCd === "0") {
|
||||
form?.setValue("daddr", "");
|
||||
@@ -93,6 +120,7 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
|
||||
String(form.getValues("ctpvCd")),
|
||||
"cityCd"
|
||||
);
|
||||
if(ctpvCdText!=='전체')
|
||||
form?.setValue("daddr", ctpvCdText);
|
||||
}
|
||||
}, [userSggCd]);
|
||||
@@ -111,6 +139,7 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
|
||||
render={({ field }) => (
|
||||
<FormUi label="시도">
|
||||
<SelectBox
|
||||
key={`sgg-${String(userCtpvCd)}`}
|
||||
className="col-span-3"
|
||||
label={""}
|
||||
selectClass={selectClass}
|
||||
@@ -118,11 +147,7 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
|
||||
onSelectValue={(val) => {
|
||||
field.onChange(Number(val));
|
||||
}}
|
||||
value={
|
||||
typeof field.value !== "undefined"
|
||||
? field.value
|
||||
: useCityCd[0]?.val
|
||||
}
|
||||
value={field.value??useCityCd[0]?.val}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -136,13 +161,14 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
|
||||
<FormUi label="시군구">
|
||||
<SelectBox
|
||||
className="col-span-3"
|
||||
key={`sgg-${String(userSggCd)}`}
|
||||
label={""}
|
||||
selectClass={`w-full min-h-[2.9rem] ${selectClass}`}
|
||||
selectArray={useSggCd}
|
||||
onSelectValue={(val) => {
|
||||
field.onChange(Number(val));
|
||||
}}
|
||||
value={field.value}
|
||||
value={field.value??useSggCd[0]?.val}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user