62 lines
1.4 KiB
TypeScript
62 lines
1.4 KiB
TypeScript
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<MenuItem[]>(
|
|
`${ENDPOINT.CMS_SERVICE.MENU_ROLES}/${siteId}`,
|
|
);
|
|
return response.data;
|
|
};
|
|
|
|
export const getPreviewTreeMenuList = async (siteId: string) => {
|
|
const response = await client.get<TreeMenu[]>(
|
|
`${ENDPOINT.CMS_SERVICE.MENUS}/${siteId}/tree/preview`,
|
|
);
|
|
return response.data;
|
|
};
|
|
|
|
export const getAnonymouseMenuList = async (
|
|
siteId: string,
|
|
): Promise<MenuItem[]> => {
|
|
const response = await fetch(
|
|
`${BASE_URL}${ENDPOINT.CMS_SERVICE.MENU_ANONYMOUS}/user/${siteId}`,
|
|
{
|
|
method: "GET",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
},
|
|
);
|
|
return response.json();
|
|
};
|