[common/components] refactor: banner, menu, site를 기본 fetch 로 수정

This commit is contained in:
2026-07-20 17:08:36 +09:00
parent 81fc947c9d
commit 2f0448a98e
8 changed files with 65 additions and 62 deletions
+16 -20
View File
@@ -1,28 +1,24 @@
import { getApiClient } from "./client";
import { getConfig } from "@common/config";
import { ENDPOINT } from "../config";
export interface Banner {
bnrSn: number;
bnrTypeCd: string;
bnrTypeNm: string;
bnrTtl: string;
lnkgUrlAddr: string;
useYn: string;
atflCd: string;
mdfcnDt: string;
mdfr: string;
mdfrNm: string;
}
bnrSn: number;
bnrTypeCd: string;
bnrTypeNm: string;
bnrTtl: string;
lnkgUrlAddr: string;
useYn: string;
atflCd: string;
mdfcnDt: string;
mdfr: string;
mdfrNm: string;
}
const { PROXY_HOST } = getConfig();
const BASE_URL = `${PROXY_HOST}/server`;
const { PROXY_HOST } = getConfig();
const BASE_URL = `${PROXY_HOST}/server`;
const client = getApiClient();
export const getBannerList = async (siteId: string) => {
const response = await client.get<Banner[]>(
export const getBannerList = async (siteId: string): Promise<Banner[]> => {
const response = await fetch(
`${BASE_URL}${ENDPOINT.CMS_SERVICE.BANNERS}/${siteId}`,
{
method: "GET",
@@ -31,5 +27,5 @@ export const getBannerList = async (siteId: string) => {
},
},
);
return response.data;
return response.json();
};
+22 -10
View File
@@ -1,4 +1,3 @@
import { getApiClient } from "./client";
import { ENDPOINT } from "../config";
import { getConfig } from "@common/config";
@@ -27,22 +26,35 @@ export interface TreeMenu extends MenuItem {
menuHlpCn: string;
}
const client = getApiClient();
const { PROXY_HOST } = getConfig();
const BASE_URL = `${PROXY_HOST}/server`;
export const getMenuList = async (siteId: string) => {
const response = await client.get<MenuItem[]>(
`${ENDPOINT.CMS_SERVICE.MENU_ROLES}/${siteId}`,
export const getMenuList = async (siteId: string): Promise<MenuItem[]> => {
const response = await fetch(
`${BASE_URL}${ENDPOINT.CMS_SERVICE.MENU_ROLES}/${siteId}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
},
);
return response.data;
return response.json();
};
export const getPreviewTreeMenuList = async (siteId: string) => {
const response = await client.get<TreeMenu[]>(
`${ENDPOINT.CMS_SERVICE.MENUS}/${siteId}/tree/preview`,
export const getPreviewTreeMenuList = async (
siteId: string,
): Promise<TreeMenu[]> => {
const response = await fetch(
`${BASE_URL}${ENDPOINT.CMS_SERVICE.MENUS}/${siteId}/tree/preview`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
},
);
return response.data;
return response.json();
};
export const getAnonymouseMenuList = async (
+7 -13
View File
@@ -1,4 +1,3 @@
import { getApiClient } from "./client";
import { getConfig } from "@common/config";
import { ENDPOINT } from "../config";
@@ -70,17 +69,12 @@ export const getSiteInfo = async (siteId: string) => {
return response.json() as Promise<SiteInfo>;
};
const client = getApiClient();
export const getSiteList = async () => {
const response = await client.get<SiteListResponse>(
`${BASE_URL}${ENDPOINT.CMS_SERVICE.SITE_LIST}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
},
export const getSiteList = async (): Promise<SiteListResponse> => {
const response = await fetch(`${BASE_URL}${ENDPOINT.CMS_SERVICE.SITE_LIST}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
);
return response.data;
});
return response.json();
};