정보검색 팝업 초기 코드 로딩 및 최초 조회 보완

This commit is contained in:
kiminchan
2026-06-25 10:40:28 +09:00
parent be67395f13
commit d4797617a6
2 changed files with 19 additions and 27 deletions
@@ -28,9 +28,10 @@ import { openWindowPopup } from '@/features/windowPopup/lib/openWindowPopup';
type SearchModalProps = {
renderMode?: "launcher" | "popup";
autoSearchReady?: boolean;
};
const SearchModal: React.FC<SearchModalProps> = ({ renderMode = "launcher" }) => {
const SearchModal: React.FC<SearchModalProps> = ({ renderMode = "launcher", autoSearchReady = false }) => {
const {
showTable,
isSearchModalOpen, setIsSearchModalOpen,
@@ -65,6 +66,7 @@ const SearchModal: React.FC<SearchModalProps> = ({ 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<SearchModalProps> = ({ 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);
@@ -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 <SearchModal renderMode="popup" />;
return <SearchModal renderMode="popup" autoSearchReady={ctpv.length > 0 && sgg.length > 0} />;
}