Files
frontend/packages/common/components/src/api/menu.ts
T

72 lines
1.6 KiB
TypeScript

import { getAuthHeaders } from "../lib/auth-header";
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 { PROXY_HOST } = getConfig();
const BASE_URL = `${PROXY_HOST}/server`;
export const getMenuList = async (siteId: string): Promise<MenuItem[]> => {
const response = await fetch(
`${BASE_URL}${ENDPOINT.CMS_SERVICE.MENU_ROLES}/${siteId}`,
{
method: "GET",
headers: getAuthHeaders(),
credentials: "include",
},
);
return response.json();
};
export const getPreviewTreeMenuList = async (
siteId: string,
): Promise<TreeMenu[]> => {
const response = await fetch(
`${BASE_URL}${ENDPOINT.CMS_SERVICE.MENUS}/${siteId}/tree/preview`,
{
method: "GET",
headers: getAuthHeaders(),
credentials: "include",
},
);
return response.json();
};
export const getAnonymouseMenuList = async (
siteId: string,
): Promise<MenuItem[]> => {
const response = await fetch(
`${BASE_URL}${ENDPOINT.CMS_SERVICE.MENU_ANONYMOUS}/user/${siteId}`,
{
method: "GET",
headers: getAuthHeaders(),
credentials: "include",
},
);
return response.json();
};