diff --git a/apps/wr/app/(with-layout)/map/mainMap/page.tsx b/apps/wr/app/(with-layout)/map/mainMap/page.tsx index 68eb02d14..d9a25c724 100644 --- a/apps/wr/app/(with-layout)/map/mainMap/page.tsx +++ b/apps/wr/app/(with-layout)/map/mainMap/page.tsx @@ -6,7 +6,7 @@ import { mapService } from "../service"; import GisApp from "@common/business_components/ui/map/lib/gis.core"; import { SearchBar } from "@common/business_components/ui/map/searchBar/searchBar"; import { useWrStore } from "@/app/store"; -import { getFeatureCd } from "@/components/lib/func/\mapUtil"; +import { getFeatureCd } from "@/components/lib/func/mapUtil"; const Map = () => { const { comMap } = useWrStore((state) => state); diff --git a/apps/wr/app/store/common/login/index.tsx b/apps/wr/app/store/common/login/index.tsx deleted file mode 100644 index 2ddd5b495..000000000 --- a/apps/wr/app/store/common/login/index.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { cmsPostFectch } from "@/components/lib/api"; - -export const isLogin = async () => { - const headers = { - accept: "application/json", - "Content-Type": "application/json", - "X-Site-Id": "WR", - "Access-Control-Expose-Headers" : ["Authorization","refresh-token","token-id"] - }; - const param = { userId: "tuser10003", password: "test1234!" }; - await cmsPostFectch("/user-service/login",param,headers); -}; - -// export type LoginState = { -// login: {} as any; -// }; - -// export type loginType = LoginState & LoginActions; - -// export const loginState: LoginState = { -// login: {}, -// }; - -// export type LoginActions = { -// isLogin: () => void; -// }; - -// export const loginActionExport: (set: any) => LoginActions = (set: any) => { -// return { -// isLogin: async () => {}, -// }; -// }; diff --git a/apps/wr/app/store/store.tsx b/apps/wr/app/store/store.tsx index 349dd8865..6577f2a8f 100644 --- a/apps/wr/app/store/store.tsx +++ b/apps/wr/app/store/store.tsx @@ -161,7 +161,6 @@ import { type rswtStatState, type rswtStatType, } from "./stats/rswtStat"; -//import { isLogin } from "./common/login"; import { LoginApi } from "@/src/entities/auth"; import { authActionsExport, diff --git a/apps/wr/components/lib/api/index.ts b/apps/wr/components/lib/api/index.ts index 7823c2ddd..fd1287793 100644 --- a/apps/wr/components/lib/api/index.ts +++ b/apps/wr/components/lib/api/index.ts @@ -1,28 +1,39 @@ //8880 +import { AUTH_USER_ID, CLAIM_NAME } from "@/src/shared/config"; import { DEV_URL_FO, DEV_URL_WR, LOCAL_URL } from "../config/"; +import { getCookie } from "@common/components/lib/cookie"; -export const fetchType = { COMMON: "common", WR: "wr", LOCAL: "LOCAL" , CS: "CS" }; +export const fetchType = { + COMMON: "common", + WR: "wr", + LOCAL: "LOCAL", + CS: "CS", +}; export const getFetch = async (type: string, url: string) => { const div = - type === fetchType.COMMON - ? DEV_URL_FO - : type === fetchType.LOCAL - ? LOCAL_URL - : type === fetchType.CS - ? '' - : DEV_URL_WR; + type === fetchType.COMMON + ? DEV_URL_FO + : type === fetchType.LOCAL + ? LOCAL_URL + : type === fetchType.CS + ? "" + : DEV_URL_WR; + const tokenId = getCookie(AUTH_USER_ID); + const Authorization = getCookie(CLAIM_NAME); const response = await fetch(div + url, { method: "GET", headers: { accept: "application/json", + AUTH_USER_ID: tokenId ?? "", + CLAIM_NAME: Authorization ?? "", }, }); if (!response.ok) { - console.log(`오류 발생: ${response.status}`); + console.log(`오류 발생: ${response.status}`); } const contentType = response.headers.get("content-type") ?? ""; @@ -41,30 +52,34 @@ export const getFetch = async (type: string, url: string) => { a.download = filename; a.click(); window.URL.revokeObjectURL(blobUrl); - + return null; // 다운로드이므로 반환값 없음 } }; export const getFetchWithCount = async (type: string, url: string) => { const div = - type === fetchType.COMMON - ? DEV_URL_FO - : type === fetchType.LOCAL - ? LOCAL_URL - : type === fetchType.CS - ? '' - : DEV_URL_WR; + type === fetchType.COMMON + ? DEV_URL_FO + : type === fetchType.LOCAL + ? LOCAL_URL + : type === fetchType.CS + ? "" + : DEV_URL_WR; + const tokenId = getCookie(AUTH_USER_ID); + const Authorization = getCookie(CLAIM_NAME); const response = await fetch(div + url, { method: "GET", headers: { accept: "application/json", + AUTH_USER_ID: tokenId ?? "", + CLAIM_NAME: Authorization ?? "", }, }); if (!response.ok) { - console.log(`오류 발생: ${response.status}`); + console.log(`오류 발생: ${response.status}`); } const contentType = response.headers.get("content-type") ?? ""; @@ -73,7 +88,6 @@ export const getFetchWithCount = async (type: string, url: string) => { // JSON 응답 처리 const res = await response.json(); - return res; } else { // 파일 응답 처리 (ex. PDF, Excel 등) @@ -86,7 +100,7 @@ export const getFetchWithCount = async (type: string, url: string) => { a.download = filename; a.click(); window.URL.revokeObjectURL(blobUrl); - + return null; // 다운로드이므로 반환값 없음 } }; @@ -94,11 +108,15 @@ export const getFetchWithCount = async (type: string, url: string) => { export const postFectch = async (url: string, params: any, type?: string) => { const div = type === fetchType.COMMON ? DEV_URL_FO : DEV_URL_WR; + const tokenId = getCookie(AUTH_USER_ID); + const Authorization = getCookie(CLAIM_NAME); const response = await fetch(div + url, { method: "POST", headers: { accept: "application/json", "Content-Type": "application/json", + AUTH_USER_ID: tokenId ?? "", + CLAIM_NAME: Authorization ?? "", }, body: JSON.stringify(params), }); @@ -108,39 +126,25 @@ export const postFectch = async (url: string, params: any, type?: string) => { return await response.json(); }; -export const cmsPostFectch = async (url: string, params: any,headers:any) => { - const response = fetch(url, { - method: "POST", - headers:headers , - body: JSON.stringify(params), - }).then((res) => - { - console.log(' res ' , res) - console.log(' access-token ' , res.headers.get('access-token')) - console.log(' refresh-token ' , res.headers.get('refresh-token')) - console.log(' token-id ' , res.headers.get('token-id')) - - }) - - - return await response; -}; - -export const putFectch = async (url: string, params: any,type?:string) => { +export const putFectch = async (url: string, params: any, type?: string) => { const div = type === fetchType.COMMON ? DEV_URL_FO : type === fetchType.LOCAL ? LOCAL_URL : type === fetchType.CS - ? '' - : DEV_URL_WR; + ? "" + : DEV_URL_WR; + const tokenId = getCookie(AUTH_USER_ID); + const Authorization = getCookie(CLAIM_NAME); const response = await fetch(div + url, { method: "PUT", headers: { "Content-Type": "application/json", + AUTH_USER_ID: tokenId ?? "", + CLAIM_NAME: Authorization ?? "", }, body: JSON.stringify(params), }); @@ -150,25 +154,33 @@ export const putFectch = async (url: string, params: any,type?:string) => { return response; }; -export const deleteFectch = async (url: string, params?: any, type?: string) => { +export const deleteFectch = async ( + url: string, + params?: any, + type?: string +) => { const div = type === fetchType.COMMON ? DEV_URL_FO : type === fetchType.LOCAL ? LOCAL_URL : type === fetchType.CS - ? '' - : DEV_URL_WR; + ? "" + : DEV_URL_WR; + const tokenId = getCookie(AUTH_USER_ID); + const Authorization = getCookie(CLAIM_NAME); const response = await fetch(div + url, { method: "DELETE", headers: { "Content-Type": "application/json", + AUTH_USER_ID: tokenId ?? "", + CLAIM_NAME: Authorization ?? "", }, - body: params?JSON.stringify(params):undefined, + body: params ? JSON.stringify(params) : undefined, }); if (!response.ok) { throw new Error(`오류 발생: ${response.status}`); } - return await response.text(); -}; \ No newline at end of file + return await response.text(); +};