import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
import {MenuGroup, MenuItems} from "~/types/layout";
import {MENU_LINK_TYPE} from "~/types/enum/layout";
import _ from "lodash"

/**
 * Menu Mon Profil
 */
export default class MyAccessesMenuBuilder extends AbstractMenuBuilder {
  static readonly menuName = "MyAccesses"

  /**
   * Construit le menu Header Multi compte, ou null si aucune page accessible
   */
  build(): MenuGroup | null {
    const children: MenuItems = []

    _.each(this.accessProfile.multiAccesses, (access) => {
      children.push(this.createItem(access.name as string, undefined, '/switch/' + access.id, MENU_LINK_TYPE.V1))
    })

    if (children.length > 0) {
      return this.createGroup('multiAccesses', {name: 'fas fa-building'}, children)
    }

    return null
  }
}
