| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import { Ability } from '@casl/ability'
- import { NuxtConfig } from '@nuxt/types/config'
- import { AnyStore, ItemMenu, ItemsMenu, Menu } from '~/types/interfaces'
- import BaseMenu from '~/use/layout/Menus/baseMenu'
- /**
- * @category Use/layout/Menus
- * @class AccountMenu
- * Classe pour la construction du Menu Mon compte
- */
- class AccountMenu extends BaseMenu implements Menu {
- private $ability: Ability;
- private $store: AnyStore;
- /**
- * @constructor
- * Initialisation des services issues du context
- */
- constructor ($config: NuxtConfig, $ability: Ability, $store: AnyStore) {
- super($config)
- this.$ability = $ability
- this.$store = $store
- }
- /**
- * Construit le menu Header Configuration ou null si aucune page accessible
- * @return {ItemMenu | null}
- */
- getHeaderMenu (): ItemMenu | null {
- const children: ItemsMenu = []
- if (this.$ability.can('display', 'organization_page')) {
- children.push(this.constructMenu('organization_page', undefined, '/organization/edit'))
- }
- children.push(this.constructMenu('my_subscription', undefined, '/organization/subscription'))
- return children.length > 0 ? this.constructMenu('configuration', 'fa-user', undefined, undefined, children) : null
- }
- }
- export const getAccountMenu = ($config: NuxtConfig, $ability: Ability, $store: AnyStore) => new AccountMenu($config, $ability, $store).getHeaderMenu()
|