diff --git a/apps/wr/app/(with-layout)/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx b/apps/wr/app/(with-layout)/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx index a481f66a1..0e49c4c6f 100644 --- a/apps/wr/app/(with-layout)/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx +++ b/apps/wr/app/(with-layout)/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx @@ -134,19 +134,30 @@ export default function PbnstSttn() { useEffect(() => { getLaeSeCdCheck(); useInitRef.current = true; + if (!pbnstSttn.isFcltsLoaded) { + getFlcts(); // 하수재이용시설 조회 + } }, []); useEffect(() => { - if (!pbnstSttn.isInit) { - getFlcts(); // 하수재이용시설 조회 - } - }, [pbnstSttn.isInit]); - - useEffect(() => { - if (useInitRef.current === true && laeSeCd !== undefined && fclts.length > 0) { + if ( + useInitRef.current === true && + laeSeCd !== undefined && + pbnstSttn.isFcltsLoaded && + !pbnstSttn.isTableLoaded && + fclts.length > 0 + ) { pbnSttnInit("1", String(DEFAULT_LIST_SIZE), getFixedSearchValue(ref.current), searchYear, fclts); } - }, [fclts, laeSeCd, searchYear, pbnSttnInit, getFixedSearchValue]); + }, [ + fclts, + laeSeCd, + pbnstSttn.isFcltsLoaded, + pbnstSttn.isTableLoaded, + searchYear, + pbnSttnInit, + getFixedSearchValue, + ]); useEffect(() => { if (pbnstSttnRes && pbnstSttnRes.length > 0) { diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx index f89320c45..b1cf957e6 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx @@ -47,7 +47,8 @@ export type pbnstSttnState = { pbnstSttnResCount: number; excelList: []; fclts: string[]; - isInit: boolean; // wr 하수재이용시설 조회했는지 점검 + isFcltsLoaded: boolean; // wr 하수재이용시설 목록 조회 여부 + isTableLoaded: boolean; // 현황 테이블 초기 조회 여부 }; }; @@ -100,7 +101,8 @@ export const pbnstSttnStateExport: pbnstSttnState = { pbnstSearchData: [], excelList: [], fclts: [], - isInit: false, + isFcltsLoaded: false, + isTableLoaded: false, }, }; @@ -251,13 +253,13 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = ( //등록된 하수재이용시설을 조회한다. getFlcts: async () => { const fclts = await getFetch(fetchType.WR, "/reuseFc/pubFc"); - return set((state: pbnstSttnState) => ({ - pbnstSttn: { - ...state.pbnstSttn, - isInit: true, // wr 하수재이용시설을 조회 여부?? - fclts: fclts, - }, - })); + return set((state: pbnstSttnState) => ({ + pbnstSttn: { + ...state.pbnstSttn, + isFcltsLoaded: true, + fclts: fclts, + }, + })); }, //테이블 헤드를 조정한다. pbnstChSttnHead: async ( @@ -314,7 +316,7 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = ( ...state.pbnstSttn, pbnstSttnRes: pbnstSttnRes.data, pbnstSttnResCount: pbnstSttnRes.count, - // isInit: false, + isTableLoaded: true, }, }; }); @@ -348,8 +350,8 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = ( ...state.pbnstSttn, pbnstSttnRes: pbnstSttnRes.data, pbnstSttnResCount: pbnstSttnRes.count, - isInit: false, pbnstDetail: {} as customPbnst, + isTableLoaded: true, }, }; }); diff --git a/apps/wr/src/app/providers/app-provider.tsx b/apps/wr/src/app/providers/app-provider.tsx index 33f2e728a..f54dfea52 100644 --- a/apps/wr/src/app/providers/app-provider.tsx +++ b/apps/wr/src/app/providers/app-provider.tsx @@ -21,6 +21,7 @@ import { StoreProvider as WrStoreProvider, useWrStore, } from "@/app/store"; +import { usePathname } from "next/navigation"; //import { LoginApi } from "@/src/entities/auth"; //import { useEffect } from "react"; import { setCookie } from "@/src/shared/lib/cookie"; @@ -41,11 +42,15 @@ i18n.init({ function CommonCodeInitializer() { const isInit = useWrStore((state) => state.code.isInit); const initCommonCodes = useWrStore((state) => state.initCommonCodes); + const pathname = usePathname(); + const isLoginPage = + pathname === "/auth/login" || pathname?.startsWith("/auth/login/"); useEffect(() => { + if (isLoginPage) return; if (isInit) return; initCommonCodes(); - }, [isInit, initCommonCodes]); + }, [isInit, initCommonCodes, isLoginPage]); return null; }