import type { MenuGroup, MenuItem, MenuItems } from '~/types/layout' import { MENU_LINK_TYPE } from '~/types/enum/layout' import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder' /** * Menu Mon compte */ export default class AccountMenuBuilder extends AbstractMenuBuilder { static readonly menuName = 'Account' /** * Construit le menu Header Configuration ou null si aucune page accessible */ build(): MenuItem | MenuGroup | null { const children: MenuItems = [] const actions: Array = [] if (this.ability.can('display', 'my_schedule_page')) { children.push( this.createItem( 'my_schedule_page', undefined, '/my_calendar', MENU_LINK_TYPE.V1, ), ) } if (this.ability.can('display', 'attendance_bookings_page')) { children.push( this.createItem( 'attendance_bookings_menu', undefined, '/own_attendance', MENU_LINK_TYPE.V1, ), ) } if (this.ability.can('display', 'my_attendance_page')) { children.push( this.createItem( 'my_attendance', undefined, '/my_attendances/list/', MENU_LINK_TYPE.V1, ), ) } if (this.ability.can('display', 'my_invitation_page')) { children.push( this.createItem( 'my_invitation', undefined, '/my_invitations/list/', MENU_LINK_TYPE.V1, ), ) } if (this.ability.can('display', 'my_students_page')) { children.push( this.createItem( 'my_students', undefined, '/my_students/list/', MENU_LINK_TYPE.V1, ), ) } if (this.ability.can('display', 'my_students_education_students_page')) { children.push( this.createItem( 'my_students_education_students', undefined, '/my_students_education_students/list/', MENU_LINK_TYPE.V1, ), ) } if (this.ability.can('display', 'my_education_students_page')) { children.push( this.createItem( 'my_education_students', undefined, `/main/my_profile/${this.accessProfile.id}/dashboard/my_education_students/list/`, MENU_LINK_TYPE.V1, ), ) } if (this.ability.can('display', 'send_an_email_page')) { children.push( this.createItem( 'send_an_email', undefined, `/list/create/emails`, MENU_LINK_TYPE.V1, ), ) } if (this.ability.can('display', 'my_documents_page')) { children.push( this.createItem( 'my_documents', undefined, `/main/my_profile/${this.accessProfile.id}/dashboard/show/my_access_file`, MENU_LINK_TYPE.V1, ), ) } if (this.ability.can('display', 'my_profile_page')) { children.push( this.createItem( 'my_profile', undefined, `/main/my_profile/${this.accessProfile.id}/dashboard`, MENU_LINK_TYPE.V1, ), ) } if (this.ability.can('display', 'adherent_list_page')) { children.push( this.createItem( 'adherent_list', undefined, `/adherent_contacts/list/`, MENU_LINK_TYPE.V1, ), ) } this.addChildItemIfAllowed(children, 'subscription_page') if (this.ability.can('display', 'my_bills_page')) { children.push( this.createItem( 'my_bills', undefined, `/main/my_profile/${this.accessProfile.id}/dashboard/show/my_bills`, MENU_LINK_TYPE.V1, ), ) } if (this.ability.can('display', 'cmf_licence_person_page')) { children.push( this.createItem( 'print_my_licence', undefined, `/licence_cmf/user`, MENU_LINK_TYPE.V1, ), ) } actions.push( this.createItem('logout', undefined, `/logout`, MENU_LINK_TYPE.V1), ) const icon = { avatarId: this.accessProfile.avatarId, avatarByDefault: this.accessProfile.gender === 'MISTER' ? '/images/default/men-1.png' : '/images/default/women-1.png', } return this.createGroup('my_account', icon, children, actions) } }