|
1 | 1 |
|
2 | 2 | type useIdentityLifecycleReturnType = { |
3 | | - getLifecycleColor: (state: number) => string; |
4 | | - getLifecycleName: (state: number) => string; |
5 | | - getLifecycleIcon: (state: number) => string; |
6 | | - getLifecycleInfos: (state: number) => { color: string, name: string, value: number }; |
| 3 | + getLifecycleColor: (state: string) => string; |
| 4 | + getLifecycleName: (state: string) => string; |
| 5 | + getLifecycleIcon: (state: string) => string; |
| 6 | + getLifecycleInfos: (state: string) => { color: string, name: string, value: string, icon: string }; |
7 | 7 | }; |
8 | 8 |
|
9 | 9 |
|
10 | 10 | export enum IdentityLifecycle { |
11 | | - IMPORTED = 3, |
12 | | - OFFICIAL = 2, |
13 | | - ACTIVE = 1, |
14 | | - PROVISIONAL = 0, |
15 | | - INACTIVE = -1, |
16 | | - DELETED = -2, |
| 11 | + WAIT = "W", |
| 12 | + OFFICIAL = "O", |
| 13 | + ACTIVE = "A", |
| 14 | + PROVISIONAL = "P", |
| 15 | + INACTIVE = "I", |
| 16 | + DELETED = "D", |
| 17 | + |
| 18 | + // IMPORTED = 3, |
| 19 | + // OFFICIAL = 2, |
| 20 | + // ACTIVE = 1, |
| 21 | + // PROVISIONAL = 0, |
| 22 | + // INACTIVE = -1, |
| 23 | + // DELETED = -2, |
17 | 24 | } |
18 | 25 |
|
19 | 26 |
|
20 | 27 | export const IdentityLifecycleList = [ |
21 | | - { value: IdentityLifecycle.IMPORTED, text: 'Importé', color: '#F0E68C', icon: 'mdi-circle', display: true }, // Khaki |
22 | | - { value: IdentityLifecycle.OFFICIAL, text: 'Officiel', color: '#228B22', icon: 'mdi-circle', display: true }, // Forest Green |
23 | | - { value: IdentityLifecycle.ACTIVE, text: 'Actif', color: '#00FF00', icon: 'mdi-circle', display: true }, // Lime |
24 | | - { value: IdentityLifecycle.PROVISIONAL, text: 'Provisoir', color: '#FFD700', icon: 'mdi-circle', display: true }, // Gold |
25 | | - { value: IdentityLifecycle.INACTIVE, text: 'Inactif', color: '#808080', icon: 'mdi-circle', display: true }, // Gray |
26 | | - { value: IdentityLifecycle.DELETED, text: 'Supprimé', color: '#FF0000', icon: 'mdi-circle', display: true }, // Red |
| 28 | + // { value: IdentityLifecycle.IMPORTED, text: 'Importé', color: '#F0E68C', icon: 'mdi-clock', display: true }, // Khaki |
| 29 | + { value: IdentityLifecycle.OFFICIAL, text: 'Officiel', color: '#228B22', icon: 'mdi-clock', display: true }, // Forest Green |
| 30 | + { |
| 31 | + value: IdentityLifecycle.ACTIVE, text: 'Actif', color: '#00FF00', icon: 'mdi-clock-check', display: true |
| 32 | + }, // Lime |
| 33 | + { value: IdentityLifecycle.PROVISIONAL, text: 'Provisoir', color: '#FFD700', icon: 'mdi-progress-clock', display: true }, // Gold |
| 34 | + { value: IdentityLifecycle.INACTIVE, text: 'Inactif', color: '#808080', icon: 'mdi-clock-alert', display: true }, // Gray |
| 35 | + { |
| 36 | + value: IdentityLifecycle.DELETED, text: 'Supprimé', color: '#FF0000', icon: 'mdi-archive-clock', display: true |
| 37 | + }, // Red |
27 | 38 | ]; |
28 | 39 |
|
29 | 40 | export function useIdentityLifecycles(): useIdentityLifecycleReturnType { |
30 | | - function getLifecycleName(state: number): string { |
31 | | - const found = IdentityLifecycleList.find(item => item.value === state); |
32 | | - if (found && found?.display) return found.text; |
33 | | - return 'Inconnu'; |
34 | | - } |
| 41 | + function getLifecycleName(state: string): string { |
| 42 | + const found = IdentityLifecycleList.find(item => item.value === state); |
| 43 | + if (found && found?.display) return found.text; |
| 44 | + return 'Inconnu'; |
| 45 | + } |
35 | 46 |
|
36 | | - function getLifecycleColor(state: number): string { |
37 | | - const found = IdentityLifecycleList.find(item => item.value === state); |
38 | | - if (found && found?.display) return found.color; |
39 | | - return 'grey'; |
40 | | - } |
| 47 | + function getLifecycleColor(state: string): string { |
| 48 | + const found = IdentityLifecycleList.find(item => item.value === state); |
| 49 | + if (found && found?.display) return found.color; |
| 50 | + return 'grey'; |
| 51 | + } |
41 | 52 |
|
42 | | - function getLifecycleIcon(state: number): string { |
43 | | - const found = IdentityLifecycleList.find(item => item.value === state); |
44 | | - if (found && found?.display) return found.icon; |
45 | | - return 'mdi-circle'; |
46 | | - } |
| 53 | + function getLifecycleIcon(state: string): string { |
| 54 | + const found = IdentityLifecycleList.find(item => item.value === state); |
| 55 | + if (found && found?.display) return found.icon; |
| 56 | + return 'mdi-circle'; |
| 57 | + } |
47 | 58 |
|
48 | | - function getLifecycleInfos(state: number): { color: string, name: string, icon: string, value: number }{ |
49 | | - const found = IdentityLifecycleList.find(item => item.value === state); |
50 | | - if (found && found?.display) return { |
51 | | - color: found.color, |
52 | | - name: found.text, |
53 | | - icon: found.icon, |
54 | | - value: state |
55 | | - }; |
56 | | - return { |
57 | | - color: 'grey', |
58 | | - name: 'Inconnu', |
59 | | - icon: 'mdi-circle', |
60 | | - value: state |
61 | | - }; |
62 | | - } |
| 59 | + function getLifecycleInfos(state: string): { color: string, name: string, icon: string, value: string } { |
| 60 | + const found = IdentityLifecycleList.find(item => item.value === state); |
| 61 | + if (found && found?.display) return { |
| 62 | + color: found.color, |
| 63 | + name: found.text, |
| 64 | + icon: found.icon, |
| 65 | + value: state, |
| 66 | + }; |
| 67 | + return { |
| 68 | + color: 'grey', |
| 69 | + name: 'Inconnu', |
| 70 | + icon: 'mdi-help-rhombus-outline', |
| 71 | + value: state, |
| 72 | + }; |
| 73 | + } |
63 | 74 |
|
64 | 75 |
|
65 | 76 | return { getLifecycleName, getLifecycleColor, getLifecycleIcon, getLifecycleInfos }; |
|
0 commit comments