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

/**
 * Menu Paramètres
 */
export default class ParametersMenuBuilder extends AbstractMenuBuilder {
  static readonly menuName = "Parameters"

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

    if (this.ability.can('display', 'parameters_page')) {
      children.push(this.createItem('general_params', {name: 'fas fa-cogs'},`/parameters`, MENU_LINK_TYPE.V1))
    }
    if (this.ability.can('display', 'parameters_communication_page')) {
      children.push(this.createItem('communication_params', {name: 'fas fa-comments'},`/parameters/communication`, MENU_LINK_TYPE.V1))
    }
    if (this.ability.can('display', 'parameters_student_page')) {
      children.push(this.createItem('students_params', {name: 'fas fa-users'},`/parameters/student`, MENU_LINK_TYPE.V1))
    }
    if (this.ability.can('display', 'parameters_education_page')) {
      children.push(this.createItem('education_params', {name: 'fas fa-graduation-cap'},`/parameters/education`, MENU_LINK_TYPE.V1))
    }
    if (this.ability.can('display', 'parameters_bills_page')) {
      children.push(this.createItem('bills_params', {name: 'fas fa-euro-sign'},`/parameters/billing`, MENU_LINK_TYPE.V1))
    }
    if (this.ability.can('display', 'parameters_secure_page')) {
      children.push(this.createItem('secure_params', {name: 'fas fa-lock'},`/parameters/secure`, MENU_LINK_TYPE.V1))
    }

    if (children.length > 0) {
      return this.createGroup('parameters', undefined, children)
    }

    return null
  }
}
