import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
import type {MenuGroup, MenuItems} from "~/types/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')) {
      return null
    }

    children.push(this.createItem('general_parameters', {name: 'fas fa-gears'},`/parameters/general_parameters`))
    children.push(this.createItem('website', {name: 'fas fa-globe-americas'},`/parameters/website`))

    if (this.organizationProfile.isSchool) {
      children.push(this.createItem('teaching', {name: 'fas fa-school'}, `/parameters/teaching`))
      children.push(this.createItem('intranet_breadcrumbs', {name: 'fas fa-arrows-down-to-people'}, `/parameters/intranet`))
      children.push(this.createItem('educationNotations', {name: 'fas fa-graduation-cap'}, `/parameters/education_notation`))
      children.push(this.createItem('bulletin', {name: 'fas fa-file-lines'}, `/parameters/bulletin`))
      children.push(this.createItem('education_timings_breadcrumbs', {name: 'fas fa-clock'}, `/parameters/education_timings`))
      children.push(this.createItem('attendance', {name: 'fas fa-user-times'}, `/parameters/attendances`))
      children.push(this.createItem('residenceAreas', {name: 'fas fa-location-dot'}, `/parameters/residence_areas`))
    }

    if (this.organizationProfile.hasModule('Sms')) {
      children.push(this.createItem('sms_option', {name: 'fas fa-mobile'}, `/parameters/sms`))
    }

    children.push(this.createItem('super_admin', {name: 'fas fa-user-gear'},`/parameters/super_admin`))

    // Voir nouveau découpage?
    // 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
  }
}
