import api, { unwrap } from './request';

export interface MenuResp {
  menuId: number;
  parentMenuId?: number;
  menuCode: string;
  menuName: string;
  menuType: 'DIRECTORY' | 'PAGE' | 'LINK';
  menuPath?: string;
  menuIcon?: string;
  componentPath?: string;
  menuLevel: number;
  sortOrder: number;
  permissions: string[];
  children: MenuResp[];
}

export const menuApi = {
  myMenus: () => unwrap<MenuResp[]>(api.get('/api/menus/my')),
  tree: () => unwrap<MenuResp[]>(api.get('/api/menus/tree')),
};
