후보지 선택 후 수요정보에 입력, 저장 시 넘어가는 데이터 테스트 필요

This commit is contained in:
jsyang
2026-04-01 15:31:37 +09:00
parent e7f4da2322
commit df7a66b2c7
@@ -15,6 +15,7 @@ import CandidateSiteModal, { type CandidateSite } from "@/components/CandidateSi
import { useDmStore} from "@/app/store";
import type { SdmInfoFormData } from "@/app/store/sdmMng";
import SimilarCaseModal, { type SimilarCaseDetail, type SimilarCaseRow } from "@/app/(landing)/reuse/apply/modal/SimilarCaseModal";
import type { SubsInfo } from "@/app/store/map/type";
type PHRange = { min: string; max: string };
@@ -58,6 +59,7 @@ export default function DemandRegisterPage() {
const [cand1, setCand1] = useState("");
const [cand2, setCand2] = useState("");
const [cand3, setCand3] = useState("");
const [candidateList, setCandidateList] = useState<SubsInfo[]>([]);
const useTypesData = useDmStore((state) => state.Sdm.useTypesData);
const getUseTypesData = useDmStore((state) => state.getUseTypesData);
@@ -76,6 +78,28 @@ export default function DemandRegisterPage() {
getUseTypesData();
}, [getUseTypesData]);
useEffect(() => {
const handler = (event: MessageEvent) => {
if (!event.data) return;
if (event.data.type === "SET_SUBS_INFO") {
const list = event.data.payload || [];
// 최대 3개
setCand1(list[0]?.ruseUtztnFcltNm || "");
setCand2(list[1]?.ruseUtztnFcltNm || "");
setCand3(list[2]?.ruseUtztnFcltNm || "");
setCandidateList(list);
}
};
window.addEventListener("message", handler);
return () => {
window.removeEventListener("message", handler);
};
}, []);
// option
// 'req':필수 / 'num' : 숫자 / 'num+[숫자] : 자릿수
const validation = (val, text, option :string[]=[] ) => {
@@ -226,7 +250,8 @@ export default function DemandRegisterPage() {
smll : odor,
cdtnv : Number(ec)||null,
crmty : Number(color)||null,
rmrk : remark
rmrk : remark,
splyCndtList : candidateList
}
insertSdmInfoData(payload);
}