11type useIdentityStateReturnType = {
2- getStateColor : ( state : number ) => string ;
3- getStateName : ( state : number ) => string ;
4- getStateInfos : ( state : number ) => { color : string , name : string , value : number } ;
2+ getStateColor : ( state : number ) => string ;
3+ getStateName : ( state : number ) => string ;
4+ getStateInfos : ( state : number ) => { color : string , name : string , value : number } ;
55} ;
66
77export enum IdentityState {
@@ -16,46 +16,45 @@ export enum IdentityState {
1616}
1717
1818export const IdentityStateList = [
19- { value : IdentityState . SYNCED , text : 'Synchronisée' , color : 'info ' , icon : 'mdi-circle' , display : true } ,
20- { value : IdentityState . TO_SYNC , text : 'A Synchroniser' , color : 'info ' , icon : 'mdi-circle' , display : true } ,
21- { value : IdentityState . TO_VALIDATE , text : 'A valider' , color : 'positive ' , icon : 'mdi-circle' , display : true } ,
22- { value : IdentityState . UNKNOWN , text : 'Inconnu' , color : 'grey' , icon : 'mdi-circle' , display : true } ,
23- { value : IdentityState . TO_CREATE , text : 'A créer' , color : 'grey' , icon : 'mdi-circle' , display : false } ,
24- { value : IdentityState . TO_COMPLETE , text : 'A compléter' , color : 'warning' , icon : 'mdi-circle' , display : true } ,
25- { value : IdentityState . ON_ERROR , text : 'En erreur' , color : 'negative' , icon : 'mdi-circle' , display : true } ,
26- { value : IdentityState . PROCESSING , text : 'En cours de synchronisation' , color : 'warning' , icon : 'mdi-loading' , display : true } ,
19+ { value : IdentityState . SYNCED , text : 'Synchronisée' , color : 'positive ' , icon : 'mdi-circle' , display : true } ,
20+ { value : IdentityState . TO_SYNC , text : 'A Synchroniser' , color : 'ambre ' , icon : 'mdi-circle' , display : true } ,
21+ { value : IdentityState . TO_VALIDATE , text : 'A valider' , color : 'info ' , icon : 'mdi-circle' , display : true } ,
22+ { value : IdentityState . UNKNOWN , text : 'Inconnu' , color : 'grey' , icon : 'mdi-circle' , display : true } ,
23+ { value : IdentityState . TO_CREATE , text : 'A créer' , color : 'grey' , icon : 'mdi-circle' , display : false } ,
24+ { value : IdentityState . TO_COMPLETE , text : 'A compléter' , color : 'warning' , icon : 'mdi-circle' , display : true } ,
25+ { value : IdentityState . ON_ERROR , text : 'En erreur' , color : 'negative' , icon : 'mdi-circle' , display : true } ,
26+ { value : IdentityState . PROCESSING , text : 'En cours de synchronisation' , color : 'warning' , icon : 'mdi-loading' , display : true } ,
2727] ;
2828
29- export function useIdentityStates ( ) : useIdentityStateReturnType
30- {
31- function getStateColor ( state : number ) : string {
32- const found = IdentityStateList . find ( item => item . value === state ) ;
33- if ( found && found ?. display ) return found . color ;
34- return 'grey' ;
35- }
36-
37- function getStateName ( state : number ) : string {
38- const found = IdentityStateList . find ( item => item . value === state ) ;
39- if ( found && found ?. display ) return found . text ;
40- return 'Inconnu' ;
41- }
42-
43- function getStateIcon ( state : number ) : string {
44- const found = IdentityStateList . find ( item => item . value === state ) ;
45- if ( found && found ?. display ) return found . icon ;
46- return 'mdi-circle' ;
47- }
48-
49- function getStateInfos ( state : number ) : { color : string , name : string , icon : string , value : number } {
50- const found = IdentityStateList . find ( item => item . value === state ) ;
51- return {
52- color : found ? found . color : 'grey' ,
53- name : found ? found . text : 'Unknown' ,
54- icon : found ? found . icon : 'mdi-circle' ,
55- value : state
56- } ;
57- }
58-
59- return { getStateColor, getStateName, getStateInfos} ;
29+ export function useIdentityStates ( ) : useIdentityStateReturnType {
30+ function getStateColor ( state : number ) : string {
31+ const found = IdentityStateList . find ( item => item . value === state ) ;
32+ if ( found && found ?. display ) return found . color ;
33+ return 'grey' ;
34+ }
35+
36+ function getStateName ( state : number ) : string {
37+ const found = IdentityStateList . find ( item => item . value === state ) ;
38+ if ( found && found ?. display ) return found . text ;
39+ return 'Inconnu' ;
40+ }
41+
42+ function getStateIcon ( state : number ) : string {
43+ const found = IdentityStateList . find ( item => item . value === state ) ;
44+ if ( found && found ?. display ) return found . icon ;
45+ return 'mdi-circle' ;
46+ }
47+
48+ function getStateInfos ( state : number ) : { color : string , name : string , icon : string , value : number } {
49+ const found = IdentityStateList . find ( item => item . value === state ) ;
50+ return {
51+ color : found ? found . color : 'grey' ,
52+ name : found ? found . text : 'Unknown' ,
53+ icon : found ? found . icon : 'mdi-circle' ,
54+ value : state
55+ } ;
56+ }
57+
58+ return { getStateColor, getStateName, getStateInfos } ;
6059}
6160
0 commit comments