@@ -7,13 +7,20 @@ import {fr} from 'date-fns/locale'
7
7
import Loader from '@/components/loader.js'
8
8
import { getAllChanges } from '@/lib/suivi-pcrs.js'
9
9
import colors from '@/styles/colors.js'
10
+ import { getUpdateStatus } from '@/lib/utils/projet.js'
10
11
11
12
const Changes = ( { token} ) => {
12
13
const [ changes , setChanges ] = useState ( )
13
14
const [ search , setSearch ] = useState ( )
14
15
const [ error , setError ] = useState ( )
15
16
const [ filteredChanges , setFilteredChanges ] = useState ( )
16
17
18
+ const changesDict = {
19
+ deleted : 'Suppression' ,
20
+ updated : 'Mise à jour' ,
21
+ created : 'Création'
22
+ }
23
+
17
24
const getChanges = useCallback ( async ( ) => {
18
25
const response = await getAllChanges ( token )
19
26
@@ -24,18 +31,6 @@ const Changes = ({token}) => {
24
31
}
25
32
} , [ token ] )
26
33
27
- function returnLastChange ( change ) {
28
- if ( change . _deleted ) {
29
- return 'Suppression'
30
- }
31
-
32
- if ( change . _updated !== change . _created ) {
33
- return 'Mise à jour'
34
- }
35
-
36
- return 'Création'
37
- }
38
-
39
34
useEffect ( ( ) => {
40
35
if ( changes ?. length > 0 && search ) {
41
36
setFilteredChanges ( changes . filter ( p => p . nom . toLowerCase ( ) . includes ( search . toLowerCase ( ) ) ) )
@@ -77,7 +72,7 @@ const Changes = ({token}) => {
77
72
</ thead >
78
73
< tbody >
79
74
{ filteredChanges . map ( change => {
80
- const lastChange = returnLastChange ( change )
75
+ const lastChange = changesDict [ getUpdateStatus ( change ) ]
81
76
const modificationTime = new Date ( change . _updated )
82
77
83
78
return (
0 commit comments