import { ItemMenu, ItemsMenu, Menu } from '~/types/interfaces' import BaseMenu from '~/composables/layout/Menus/baseMenu' import {useProfileAccessStore} from "~/store/profile/access"; import {useAbility} from "@casl/vue"; /** * @category composables/layout/Menus * @class AccountMenu * Classe pour la construction du Menu Mon compte */ class AccountMenu extends BaseMenu implements Menu { /** * @constructor * Initialisation des services issues du context */ constructor () { const {$config} = useNuxtApp() super($config) } /** * Construit le menu Header Configuration ou null si aucune page accessible * @return {ItemMenu | null} */ getHeaderMenu (): ItemMenu | null { const profileAccessStore = useProfileAccessStore(); const {can} = useAbility() const children: ItemsMenu = [] if (can('display', 'my_schedule_page')) { children.push(this.constructMenu('my_schedule_page', undefined, '/my_calendar', true)) } if (can('display', 'attendance_bookings_page')) { children.push(this.constructMenu('attendance_bookings_menu', undefined, '/own_attendance', true)) } if (can('display', 'my_attendance_page')) { children.push(this.constructMenu('my_attendance', undefined, '/my_attendances/list/', true)) } if (can('display', 'my_invitation_page')) { children.push(this.constructMenu('my_invitation', undefined, '/my_invitations/list/', true)) } if (can('display', 'my_students_page')) { children.push(this.constructMenu('my_students', undefined, '/my_students/list/', true)) } if (can('display', 'my_students_education_students_page')) { children.push(this.constructMenu('my_students_education_students', undefined, '/my_students_education_students/list/', true)) } if (can('display', 'criteria_notations_page') || can('display', 'criteria_notations_page_from_account_menu')) { children.push(this.constructMenu('criteria_notations', undefined, '/criteria_notations/list/', true)) } if (can('display', 'my_education_students_page')) { children.push(this.constructMenu('my_education_students', undefined, `/main/my_profile/${profileAccessStore.id}/dashboard/my_education_students/list/`, true)) } if (can('display', 'send_an_email_page')) { children.push(this.constructMenu('send_an_email', undefined, `/list/create/emails`, true)) } if (can('display', 'my_documents_page')) { children.push(this.constructMenu('my_documents', undefined, `/main/my_profile/${profileAccessStore.id}/dashboard/show/my_access_file`, true)) } if (can('display', 'my_profile_page')) { children.push(this.constructMenu('my_profile', undefined, `/main/my_profile/${profileAccessStore.id}/dashboard`, true)) } if (can('display', 'adherent_list_page')) { children.push(this.constructMenu('adherent_list', undefined, `/adherent_contacts/list/`, true)) } if (can('display', 'subscription_page')) { children.push(this.constructMenu('my_subscription', undefined, `/subscription`)) } if (can('display', 'my_bills_page')) { children.push(this.constructMenu('my_bills', undefined, `/main/my_profile/${profileAccessStore.id}/dashboard/show/my_bills`, true)) } if (can('display', 'cmf_licence_person_page')) { children.push(this.constructMenu('print_my_licence', undefined, `/licence_cmf/user`, true)) } const accountMenu = this.constructMenu('my_account', { avatarId: profileAccessStore.avatarId, avatarByDefault: profileAccessStore.gender == 'MISTER' ? 'men-1.png' : 'women-1.png' }, undefined, undefined, children, false) const actions: ItemsMenu = []; actions.push(this.constructMenu('logout', undefined, `/logout`, true)) accountMenu.actions = actions return accountMenu } } export const getAccountMenu = () => new AccountMenu().getHeaderMenu()