diff --git a/apps/sn/src/entities/auth/api/login-service.ts b/apps/sn/src/entities/auth/api/login-service.ts index c1968fe36..dd5a49f68 100644 --- a/apps/sn/src/entities/auth/api/login-service.ts +++ b/apps/sn/src/entities/auth/api/login-service.ts @@ -23,6 +23,7 @@ export class LoginApiService implements LoginService { public async login(payload: ILogin): Promise { try { + tokenManager.clearAuthToken(); const response = await fetch(`/api/proxy${ENDPOINT.USER_SERVICE.LOGIN}`, { method: "POST", body: JSON.stringify({ diff --git a/apps/wr/app/(map-layout)/map/mainMap/page.tsx b/apps/wr/app/(map-layout)/map/mainMap/page.tsx index a2addf109..13798ff4f 100644 --- a/apps/wr/app/(map-layout)/map/mainMap/page.tsx +++ b/apps/wr/app/(map-layout)/map/mainMap/page.tsx @@ -21,7 +21,8 @@ import WrOverLay from "@/components/ui/map/wrOverLay/wrOverLay"; const Map = () => { - const { code, comMap, rainMapDetile, rswtMapDetile, getRuseMaplListReturn, pbnMapDetaile, ldrmntMapDetile, htdfMapDetile, coSttnMapDetail } = useWrStore((state) => state); + const { code, comMap, rainMapDetile, rswtMapDetile, getRuseMaplListReturn + , pbnMapDetaile, ldrmntMapDetile, htdfMapDetile, coSttnMapDetail } = useWrStore((state) => state); const { isFeatured } = comMap; const [treeData, setTreeData] = useState([]); // 초기값을 객체 또는 null로 설정 const gisMaps = useRef(null); diff --git a/apps/wr/app/(with-layout)/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/(with-layout)/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 0a243a41f..5cf8fc0d5 100644 --- a/apps/wr/app/(with-layout)/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/(with-layout)/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -287,7 +287,7 @@ export default function PublicReuseFaciltyInsert() { }, [pbnstRes, append, selectRow]); useEffect(() => { - pubHasuInit(String(pageNation), laeSeCd); + pubHasuInit(String(pageNation), laeSeCd); // 해당 지자체의 하수처리시설 조회 isResetPage(false); setSelectRow(undefined); setSelectedRowIndex(-1); 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 3e085ea89..23d7bb4e8 100644 --- a/apps/wr/app/(with-layout)/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx +++ b/apps/wr/app/(with-layout)/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx @@ -36,6 +36,7 @@ import { useTranslation } from "react-i18next"; export default function PbnstSttn() { const { + auth, code, pbnstSttn, pbnstSttnSearch, @@ -43,9 +44,11 @@ export default function PbnstSttn() { getPbnStnDetail, getFlcts, resetPbnstDetail, + getLaeSeCdCheck, } = useWrStore((state) => state); const { pbnstSttnRes, fclts, pbnstSttnResCount } = pbnstSttn; + const { laeSeCd } = auth; const [isReset, setIsReset] = useState(false); const ref = useRef({} as ReturnType); @@ -59,21 +62,53 @@ export default function PbnstSttn() { data: customPbnst; }>({ isModal: false, data: {} as customPbnst }); const isDownloadTriggered = useRef(false); + const useInitRef = useRef(false); const [pbnRuseNm, setPbnRuseNm] = useState(""); const { t } = useTranslation("base"); const alert = useAlertStore((state) => state.setMessage); + const isAllAreaUser = laeSeCd === "0"; + const fixedSidoValue = + !isAllAreaUser && laeSeCd?.length ? laeSeCd.slice(0, 2) : ""; + const fixedSigunValue = + !isAllAreaUser && laeSeCd?.length === 5 ? laeSeCd : "0"; + const getFixedSearchValue = useCallback( + (baseValue: ReturnType): ReturnType => { + if (isAllAreaUser) { + return baseValue; + } + + const fixedSidoText = + code.cityCd.find((item) => item.val === fixedSidoValue)?.text ?? ""; + const fixedSigunText = + fixedSigunValue !== "0" + ? code.sggCd.find((item) => item.val === fixedSigunValue)?.text ?? "" + : ""; + + return { + ...baseValue, + partValue: "A", + sidoValue: fixedSidoValue, + sigunValue: fixedSigunValue, + sidoText: fixedSidoText, + sigunText: fixedSigunText, + }; + }, + [isAllAreaUser, fixedSidoValue, fixedSigunValue, code.cityCd, code.sggCd] + ); + const excelClick = useCallback(() => { isDownloadTriggered.current = true; + const fixedSearchValue = getFixedSearchValue(ref.current); pbnstSttnSearch( true, String(1), "100000", - ref.current, + fixedSearchValue, pbnRuseNm, searchYear, fclts ); - }, [pbnstSttnSearch, fclts, pbnRuseNm]); + }, [pbnstSttnSearch, fclts, pbnRuseNm, searchYear, getFixedSearchValue]); const cellCLick = useCallback( (index: number | undefined) => { @@ -84,14 +119,21 @@ export default function PbnstSttn() { }, [getPbnStnDetail, pbnstSttnRes] ); + useEffect(() => { + getLaeSeCdCheck(); + useInitRef.current = true; + }, []); + useEffect(() => { if (!pbnstSttn.isInit) { getFlcts(); } }, [pbnstSttn.isInit]); useEffect(() => { - pbnSttnInit("1", "15", ref.current, searchYear, fclts); - }, [fclts]); + if (useInitRef.current === true && laeSeCd !== undefined && fclts.length > 0) { + pbnSttnInit("1", "15", getFixedSearchValue(ref.current), searchYear, fclts); + } + }, [fclts, laeSeCd, searchYear, pbnSttnInit, getFixedSearchValue]); useEffect(() => { if (pbnstSttnRes && pbnstSttnRes.length > 0) { @@ -139,8 +181,18 @@ export default function PbnstSttn() {
item.val === fixedSidoValue) + : code.cityCd + } + selectSigunData={ + !isAllAreaUser && laeSeCd?.length === 5 + ? code.sggCd.filter((item) => item.val === laeSeCd) + : !isAllAreaUser && laeSeCd?.length === 2 + ? code.sggCd.filter((item) => item.val.slice(0, 2) === laeSeCd) + : code.sggCd + } selectRegionData={code.rvbsnCd} selectUnitWaterShedData={code.lgbsnCd} selectMiddleRegionData={code.mdmbsnCd} @@ -185,9 +237,16 @@ export default function PbnstSttn() {
} queryClick={() => { - // pbnSearch(returnType); - - //setTableIndex(0) + const fixedSearchValue = getFixedSearchValue(ref.current); + pbnstSttnSearch( + false, + "1", + String(prfRegPageSize), + fixedSearchValue, + pbnRuseNm, + searchYear, + fclts + ); setIsReset(true); }} excelClick={excelClick} @@ -196,7 +255,8 @@ export default function PbnstSttn() { }} btnClass={btnClass} ref={ref} - isAdmin={false} + isAdmin={!isAllAreaUser} + initSidoValue={fixedSidoValue} />
@@ -215,11 +275,12 @@ export default function PbnstSttn() { cellCLick(index); }} onPageChange={(page: number) => { + const fixedSearchValue = getFixedSearchValue(ref.current); pbnstSttnSearch( false, String(page), String(prfRegPageSize), - ref.current, + fixedSearchValue, pbnRuseNm, searchYear, fclts diff --git a/apps/wr/app/store/common/auth/index.tsx b/apps/wr/app/store/common/auth/index.tsx index e213bafa3..feca57c80 100644 --- a/apps/wr/app/store/common/auth/index.tsx +++ b/apps/wr/app/store/common/auth/index.tsx @@ -12,7 +12,7 @@ export type authState = { mdfcnAuthrtYn: string; delAuthrtYn: string; laeSeCd: string; // 지자체구분코드 - myUUID?: string; + myUUID?: string; }; }; @@ -67,17 +67,18 @@ export const authActionsExport: (set: any, get: any) => authActions = ( redirect("/"); } }, + // 로그인 사용자 지역코드 laeSeCd를 조회 후 상태 update getLaeSeCdCheck: async () => { try { const current = get().auth.laeSeCd; if (current && current !== "") { return; } - const infoMe = await getUserInfo(); - //console.log(infoMe); + const infoMe = await getUserInfo(); // 로그인 사용자의 정보 조회 + // console.log(infoMe); const isLaeSeCd = - infoMe.laeSeCd.slice(0, 2) === "G3" ? infoMe.laeSeCd.slice(2) : "0"; - + infoMe.laeSeCd.slice(0, 2) === "G3" ? infoMe.laeSeCd.slice(2) : "0"; //G341830 + // console.log("isLaeSeCd",isLaeSeCd); set((state: authState) => ({ ...state, auth: { diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index 35458abd5..b1ae27e1b 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -99,18 +99,18 @@ export const pubFacStateExport: pubFacState = { pbnstHasuResCount: 1, }, }; - +// 재사용시설에 대한 정보 조회 export const checkWrRegList = async () => { const wrRegList = await getFetch("wr", `/reuseFc/pubFc`); return wrRegList; }; - +// 하수처리시설 정보 조회 const hasuListFetch = async ( page: string, - sggOrCity: string, + sggOrCity: string, // 해당 지자체의 하수처리시설 조회 searchTxt?: string ) => { - const checkWrRegListRes = await checkWrRegList(); + const checkWrRegListRes = await checkWrRegList(); // 재사용시설에 대한 정보 조회 let url = `/prcsFclt/ruseInfo/${page ? page : 1}/11/A/${sggOrCity ? sggOrCity : "11"}/0/1/SW`; diff --git a/packages/common/network/utils.ts b/packages/common/network/utils.ts index 010bf2fe2..ac92db852 100644 --- a/packages/common/network/utils.ts +++ b/packages/common/network/utils.ts @@ -7,14 +7,14 @@ export function getAuthLoginRedirectUrl(): string { } export function isAtLoginRedirectUrl(loginRedirectUrl: string): boolean { - if (typeof window === "undefined") return false; + if (typeof window === "undefined") return false; // 서버 환경에서는 현재 브라우저 URL을 알 수 없으므로 false 반환 try { - const target = new URL(loginRedirectUrl, window.location.href); + const target = new URL(loginRedirectUrl, window.location.href); // 상대경로/절대경로 모두 현재 주소 기준의 완전한 URL로 변환 return ( - target.origin === window.location.origin && - target.pathname === window.location.pathname + target.origin === window.location.origin && // 도메인(프로토콜 + 호스트 + 포트)이 같은지 확인 + target.pathname === window.location.pathname // 현재 페이지 경로가 로그인 이동 경로와 같은지 확인 ); } catch { - return false; + return false; // 잘못된 URL 문자열이면 비교할 수 없으므로 false 반환 } }