accountMenuBuilder.ts 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import type {MenuGroup, MenuItem, MenuItems} from '~/types/layout'
  2. import {MENU_LINK_TYPE} from "~/types/enum/layout";
  3. import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
  4. /**
  5. * Menu Mon compte
  6. */
  7. export default class AccountMenuBuilder extends AbstractMenuBuilder {
  8. static readonly menuName = "Account"
  9. /**
  10. * Construit le menu Header Configuration ou null si aucune page accessible
  11. */
  12. build (): MenuItem | MenuGroup | null {
  13. const children: MenuItems = []
  14. const actions: Array<MenuItem> = []
  15. if (this.ability.can('display', 'my_schedule_page')) {
  16. children.push(this.createItem('my_schedule_page', undefined, '/my_calendar', MENU_LINK_TYPE.V1))
  17. }
  18. if (this.ability.can('display', 'attendance_bookings_page')) {
  19. children.push(this.createItem('attendance_bookings_menu', undefined, '/own_attendance', MENU_LINK_TYPE.V1))
  20. }
  21. if (this.ability.can('display', 'my_attendance_page')) {
  22. children.push(this.createItem('my_attendance', undefined, '/my_attendances/list/', MENU_LINK_TYPE.V1))
  23. }
  24. if (this.ability.can('display', 'my_invitation_page')) {
  25. children.push(this.createItem('my_invitation', undefined, '/my_invitations/list/', MENU_LINK_TYPE.V1))
  26. }
  27. if (this.ability.can('display', 'my_students_page')) {
  28. children.push(this.createItem('my_students', undefined, '/my_students/list/', MENU_LINK_TYPE.V1))
  29. }
  30. if (this.ability.can('display', 'my_students_education_students_page')) {
  31. children.push(this.createItem('my_students_education_students', undefined, '/my_students_education_students/list/', MENU_LINK_TYPE.V1))
  32. }
  33. if (this.ability.can('display', 'my_education_students_page')) {
  34. children.push(this.createItem('my_education_students', undefined, `/main/my_profile/${this.accessProfile.id}/dashboard/my_education_students/list/`, MENU_LINK_TYPE.V1))
  35. }
  36. if (this.ability.can('display', 'send_an_email_page')) {
  37. children.push(this.createItem('send_an_email', undefined, `/list/create/emails`, MENU_LINK_TYPE.V1))
  38. }
  39. if (this.ability.can('display', 'my_documents_page')) {
  40. children.push(this.createItem('my_documents', undefined, `/main/my_profile/${this.accessProfile.id}/dashboard/show/my_access_file`, MENU_LINK_TYPE.V1))
  41. }
  42. if (this.ability.can('display', 'my_profile_page')) {
  43. children.push(this.createItem('my_profile', undefined, `/main/my_profile/${this.accessProfile.id}/dashboard`, MENU_LINK_TYPE.V1))
  44. }
  45. if (this.ability.can('display', 'adherent_list_page')) {
  46. children.push(this.createItem('adherent_list', undefined, `/adherent_contacts/list/`, MENU_LINK_TYPE.V1))
  47. }
  48. if (this.ability.can('display', 'subscription_page')) {
  49. children.push(this.createItem('my_subscription', undefined, `/subscription`))
  50. }
  51. if (this.ability.can('display', 'my_bills_page')) {
  52. children.push(this.createItem('my_bills', undefined, `/main/my_profile/${this.accessProfile.id}/dashboard/show/my_bills`, MENU_LINK_TYPE.V1))
  53. }
  54. if (this.ability.can('display', 'cmf_licence_person_page')) {
  55. children.push(this.createItem('print_my_licence', undefined, `/licence_cmf/user`, MENU_LINK_TYPE.V1))
  56. }
  57. actions.push(this.createItem('logout', undefined, `/logout`, MENU_LINK_TYPE.V1))
  58. const icon = {
  59. avatarId: this.accessProfile.avatarId,
  60. avatarByDefault: this.accessProfile.gender == 'MISTER' ? '/images/default/men-1.png' : '/images/default/women-1.png'
  61. }
  62. return this.createGroup('my_account', icon, children, actions)
  63. }
  64. }