import { action, observable, makeObservable } from 'mobx';
import { IMenuData, IAction, ICompany, IOrganization } from '@/api/Types';
import * as React from 'react';

export class AppStore {
  constructor() {
    makeObservable(this);
  }

  @observable
  menu: Partial<IMenuData> = {} ;

  @observable
  menus: IMenuData[] = [];

  @observable
  breadcrumbs: [] = [];

  @observable
  topMenu: IMenuData[] = []; // 管理端顶部菜单

  @observable
  topActions: IAction[] | React.ReactNode = [] ;

  @action
  setMenu = (menu: IMenuData) => {
    this.menu = menu;
  };

  @action
  getMenu = () => {
    return this.menu;
  };

  @action
  setMenus = (menus: IMenuData[]) => {
    this.menus = menus;
  };

  @action
  getMenus = () => {
    return this.menus;
  };

  @action
  setBreadcrumbs = (breadcrumbs: []) => {
    this.breadcrumbs = breadcrumbs;
  };

  @action
  setTopMenu = (topMenu: IMenuData[]) => {
    this.topMenu = topMenu;
  };

  @action
  getTopMenu = () => {
    return this.topMenu;
  };

  @action
  setTopActions = (topActions: IAction[]) => {
    this.topActions = topActions;
  };

  @action
  getTopActions = () => {
    return this.topActions;
  };
}

export const appStore = new AppStore();
