@@ -3,7 +3,8 @@ import { useIdentityStates } from './useIdentityStates'
33import { DefaultMenuParts , MaxMenuBadgeCount , MenuPart } from '~/constants/variables'
44import { IdentityState } from '~/constants/enums'
55import qs from 'qs'
6- import path from 'path'
6+ import type { useIdentityStateStore } from '~/stores/identityState'
7+ import { sort } from 'radash'
78
89const { getStateBadge } = useIdentityStates ( )
910const config = useAppConfig ( )
@@ -15,8 +16,16 @@ type useMenuReturnType = {
1516 initialize : ( ) => Promise < void >
1617}
1718
18- function useMenu ( identityStateStore ) : useMenuReturnType {
19+ function useMenu ( identityStateStore : ReturnType < typeof useIdentityStateStore > ) : useMenuReturnType {
1920 const menuParts = ref ( DefaultMenuParts )
21+
22+ if ( config ?. menus ?. parts ) {
23+ menuParts . value = sort ( [ ...menuParts . value , ...( config . menus ?. parts as any ) || [ ] ] , ( part ) => {
24+ const pos = part . position || 9_999
25+ return pos
26+ } )
27+ }
28+
2029 const menus = ref < MenuItem [ ] > ( [
2130 {
2231 icon : 'mdi-account' ,
@@ -116,8 +125,9 @@ function useMenu(identityStateStore): useMenuReturnType {
116125 icon : 'mdi-account-switch-outline' ,
117126 label : 'Fusionnées' ,
118127 path : '/identities/table?sort[metadata.lastUpdatedAt]=desc&skip=0&filters[!:primaryEmployeeNumber]=null' ,
119- color : 'grey-3' ,
120- textColor : 'black' ,
128+ color : 'linear-gradient(135deg, #7C3AED 0%, #EC4899 50%, #F97316 100%)' ,
129+ textColor : 'white' ,
130+ badge : { color : 'linear-gradient(135deg, #7C3AED 0%, #EC4899 50%, #F97316 100%)' , textColor : 'white' } ,
121131 part : MenuPart . ETATS ,
122132 hideInMenuBar : false ,
123133 } ,
@@ -178,11 +188,8 @@ function useMenu(identityStateStore): useMenuReturnType {
178188 const menuList : MenuItem [ ] = menus . value . reduce ( ( acc : MenuItem [ ] , menu ) => {
179189 const label = normalizeLabel ( menu . label )
180190 const stateValue = identityStateStore . getStateValue ( label )
181- // console.log(`Processing menu ${label} with state value ${stateValue}`)
182191 const value = stateValue > MaxMenuBadgeCount ? MaxMenuBadgeCount + '+' : stateValue ?. toString ( ) || '0'
183192
184- // console.log(`Menu ${menu.label} has state value ${stateValue} and badge value ${value}`)
185-
186193 acc . push ( {
187194 ...menu ,
188195 badge : menu . badge ? < BadgeItem > {
@@ -212,10 +219,7 @@ function useMenu(identityStateStore): useMenuReturnType {
212219 const queryString = qs . parse ( params . toString ( ) )
213220 const qsFilters = { }
214221
215- // console.log('lab', label, 'qs', queryString)
216-
217222 for ( const [ key , value ] of Object . entries ( queryString [ 'filters' ] || { } ) ) {
218- // console.log('Processing filter ' + label, { key, value })
219223 qsFilters [ decodeURIComponent ( key ) ] = decodeURIComponent ( value as string )
220224 }
221225
0 commit comments