From 401f2dba1321ed0351a038e9b5696684b2c43f10 Mon Sep 17 00:00:00 2001 From: rsone001 Date: Mon, 6 Jul 2026 11:29:56 +0900 Subject: [PATCH] =?UTF-8?q?[ST]=20-=20SearchFrom=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/st/src/components/module/SearchForm.tsx | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/apps/st/src/components/module/SearchForm.tsx b/apps/st/src/components/module/SearchForm.tsx index 08b6e2b50..ccc76bc3d 100644 --- a/apps/st/src/components/module/SearchForm.tsx +++ b/apps/st/src/components/module/SearchForm.tsx @@ -172,6 +172,30 @@ const SearchForm = (props: SearchFormProps = {}) => { ); const sggOptions = sggList?.data ?? []; + // 시도 설정 후 시군구 목록이 오면 첫 번째 항목 자동 선택 + useEffect(() => { + if (!mergedProps.gugun) return; + if (props.defaultValues?.gugun) return; + if (!values.sido || values.sido === "ALL") return; + + const firstSgg = sggList?.data?.[0]; + if (!firstSgg) return; + + setValues((prev) => { + if (prev.gugun) return prev; + return { + ...prev, + gugun: firstSgg.gugun, + bsnmCd: firstSgg.bsnmCd, + }; + }); + }, [ + sggList, + values.sido, + mergedProps.gugun, + props.defaultValues?.gugun, + ]); + const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); props.onSubmit?.(values);