import { getApiClient } from "./client"; import { ENDPOINT } from "../config"; import { getConfig } from "@common/config"; export interface MenuItem { menuCd: number; menuKornNm: string; menuEngNm: string; parentId: number | null; sortSeq: number; iconNm?: string; children: MenuItem[] | null; levelNo: number; urlPath: string; menuLnkgTypeCd: string; menuLnkgSn: number; menuPath: string; qrcd: string; useYn: string; otptYn: string; newWndwYn: string; requiredUrlPath: boolean; menuHlpCn: string; } 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( `${ENDPOINT.CMS_SERVICE.MENU_ROLES}/${siteId}`, ); return response.data; }; export const getPreviewTreeMenuList = async (siteId: string) => { const response = await client.get( `${ENDPOINT.CMS_SERVICE.MENUS}/${siteId}/tree/preview`, ); return response.data; }; export const getAnonymouseMenuList = async ( siteId: string, ): Promise => { const response = await fetch( `${BASE_URL}${ENDPOINT.CMS_SERVICE.MENU_ANONYMOUS}/user/${siteId}`, { method: "GET", headers: { "Content-Type": "application/json", }, }, ); return response.json(); };