diff --git a/apps/sn/app/(map-layout)/map/searchModal/searchModal.tsx b/apps/sn/app/(map-layout)/map/searchModal/searchModal.tsx index 82f9f7fe3..797969427 100644 --- a/apps/sn/app/(map-layout)/map/searchModal/searchModal.tsx +++ b/apps/sn/app/(map-layout)/map/searchModal/searchModal.tsx @@ -28,9 +28,10 @@ import { openWindowPopup } from '@/features/windowPopup/lib/openWindowPopup'; type SearchModalProps = { renderMode?: "launcher" | "popup"; + autoSearchReady?: boolean; }; -const SearchModal: React.FC = ({ renderMode = "launcher" }) => { +const SearchModal: React.FC = ({ renderMode = "launcher", autoSearchReady = false }) => { const { showTable, isSearchModalOpen, setIsSearchModalOpen, @@ -65,6 +66,7 @@ const SearchModal: React.FC = ({ renderMode = "launcher" }) => handleOperationPageNation } = useOperationTab(); const hasAutoOpenedReportRef = useRef(false); + const hasAutoSearchedRef = useRef(false); const dynamicHeadlist: { id: string, title: string }[] = useMemo(() => { @@ -133,6 +135,13 @@ const SearchModal: React.FC = ({ renderMode = "launcher" }) => resetFilters(); }, [activeTab, basicType, workType]); + useEffect(() => { + if (renderMode !== "popup" || !autoSearchReady || hasAutoSearchedRef.current) return; + + hasAutoSearchedRef.current = true; + void fetchFilteredData(); + }, [autoSearchReady, fetchFilteredData, renderMode]); + // 페이지 변경 시마다 데이터 fetch useEffect(() => { setIsResetPage(false); diff --git a/apps/sn/src/features/windowPopup/ui/SearchModalPopupContent.tsx b/apps/sn/src/features/windowPopup/ui/SearchModalPopupContent.tsx index ed32a55a8..34343b6d0 100644 --- a/apps/sn/src/features/windowPopup/ui/SearchModalPopupContent.tsx +++ b/apps/sn/src/features/windowPopup/ui/SearchModalPopupContent.tsx @@ -17,32 +17,15 @@ export default function SearchModalPopupContent() { } = useStore(); useEffect(() => { - // Popup windows do not run map-layout initialization, so load search codes here. - if (ctpv.length === 0) { - void fetchCtpv(); - } + // Popup windows do not run map-layout initialization, so load location codes here. + if (ctpv.length === 0) void fetchCtpv(); + if (sgg.length === 0) void fetchSgg(); + }, [ctpv.length, fetchCtpv, fetchSgg, sgg.length]); - if (sgg.length === 0) { - void fetchSgg(); - } + useEffect(() => { + if (BIZ_SE_CD.length === 0) void fetchBIZ_SE_CD(); + if (BIZ_TY_CD.length === 0) void fetchBIZ_TY_CD(); + }, [BIZ_SE_CD.length, BIZ_TY_CD.length, fetchBIZ_SE_CD, fetchBIZ_TY_CD]); - if (BIZ_SE_CD.length === 0) { - void fetchBIZ_SE_CD(); - } - - if (BIZ_TY_CD.length === 0) { - void fetchBIZ_TY_CD(); - } - }, [ - BIZ_SE_CD.length, - BIZ_TY_CD.length, - ctpv.length, - fetchBIZ_SE_CD, - fetchBIZ_TY_CD, - fetchCtpv, - fetchSgg, - sgg.length, - ]); - - return ; + return 0 && sgg.length > 0} />; }