수요정보 등록 기능 추가

This commit is contained in:
jsyang
2026-03-25 11:44:18 +09:00
parent 645a7db2e5
commit a57c1a4a5c
131 changed files with 771 additions and 88 deletions
+53 -1
View File
@@ -1,6 +1,7 @@
//8880
import { AUTH_USER_ID, CLAIM_NAME } from "@/src/shared/config";
import { getCookie } from "@common/components/lib/cookie";
import { DEV_URL_FO, DEV_URL_WR, LOCAL_URL } from "../config/";
const tokenId = getCookie(AUTH_USER_ID);
@@ -10,7 +11,9 @@ export const fetchType = {
COMMON: "common",
WR: "wr",
FO: "fo",
SN: "sn"
SN: "sn",
LOCAL: "LOCAL",
CS: "CS",
};
const API_VERSION = "/api/v1"
@@ -44,6 +47,55 @@ export const getFetch = async (type: string, url: string) => {
return res;
};
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;
const apiUrl = div + url;
const response = await fetch(apiUrl, {
method: "GET",
headers: {
accept: "application/json",
},
});
if (!response.ok) {
console.log(`오류 발생: ${response.status}`);
}
const contentType = response.headers.get("content-type") ?? "";
if (contentType.includes("application/json")) {
// JSON 응답 처리
const res = await response.json();
return res;
} else if(contentType.includes('application/octet-stream')) {
// 파일 응답 처리 (ex. PDF, Excel 등)
console.log('contentType ' ,contentType)
const blob = await response.blob();
const blobUrl = window.URL.createObjectURL(blob);
const a = document.createElement("a");
const filename = "downloaded_file.PDF";
a.href = blobUrl;
a.download = filename;
a.click();
window.URL.revokeObjectURL(blobUrl);
return null; // 다운로드이므로 반환값 없음
}else{
throw Error('오류 발생')
}
};
export const postFetch = async (url: string, params: RequestParams) => {
const baseUrl = servers[fetchType.WR];
const response = await fetch(baseUrl + url, {