| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- 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 override readonly menuName = 'Account'
- /**
- * Construit le menu Header Configuration ou null si aucune page accessible
- */
- build(): MenuItem | MenuGroup | null {
- const children: MenuItems = []
- const actions: Array<MenuItem> = []
- 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,
- false,
- true,
- ),
- )
- }
- children.push(
- ...this.makeChildren([
- { pageName: 'subscription_page', endOfSubsection: true },
- ]),
- )
- 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,
- ),
- )
- }
- children.push(
- ...this.makeChildren([
- { pageName: 'my_settings_page', endOfSubsection: true },
- ]),
- )
- 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)
- }
- }
|