1
- import { Col , Modal , ModalContent , ModalTitle , Text } from '@dataesr/react-dsfr' ;
1
+ import {
2
+ Col ,
3
+ Modal ,
4
+ ModalContent ,
5
+ ModalTitle ,
6
+ Text ,
7
+ } from '@dataesr/react-dsfr' ;
2
8
import { useState } from 'react' ;
3
9
4
- import IdentifierForm from '../../forms/identifier' ;
5
- import ExpendableListCards from '../../card/expendable-list-cards' ;
6
- import {
7
- Bloc ,
8
- BlocActionButton ,
9
- BlocContent ,
10
- BlocModal ,
11
- BlocTitle ,
12
- } from '../../bloc' ;
13
- import KeyValueCard from '../../card/key-value-card' ;
14
10
import useEnums from '../../../hooks/useEnums' ;
15
11
import useFetch from '../../../hooks/useFetch' ;
16
12
import useNotice from '../../../hooks/useNotice' ;
17
13
import useUrl from '../../../hooks/useUrl' ;
18
14
import api from '../../../utils/api' ;
15
+ import getLink from '../../../utils/get-links' ;
19
16
import { getTvaIntraFromSiren } from '../../../utils/get-tva-intra' ;
20
17
import {
21
18
deleteError ,
22
19
deleteSuccess ,
20
+ saveDuplicate ,
23
21
saveError ,
24
22
saveSuccess ,
25
23
} from '../../../utils/notice-contents' ;
26
- import getLink from '../../../utils/get-links' ;
24
+ import {
25
+ Bloc ,
26
+ BlocActionButton ,
27
+ BlocContent ,
28
+ BlocModal ,
29
+ BlocTitle ,
30
+ } from '../../bloc' ;
31
+ import ExpendableListCards from '../../card/expendable-list-cards' ;
32
+ import KeyValueCard from '../../card/key-value-card' ;
27
33
import CopyButton from '../../copy/copy-button' ;
34
+ import IdentifierForm from '../../forms/identifier' ;
28
35
29
36
export default function IdentifiersComponent ( ) {
30
37
const { notice } = useNotice ( ) ;
@@ -40,8 +47,8 @@ export default function IdentifiersComponent() {
40
47
const method = itemId ? 'patch' : 'post' ;
41
48
const saveUrl = itemId ? `${ url } /${ itemId } ` : url ;
42
49
await api [ method ] ( saveUrl , body )
43
- . then ( ( ) => {
44
- notice ( saveSuccess ) ;
50
+ . then ( ( response ) => {
51
+ notice ( response . status === 204 ? saveDuplicate : saveSuccess ) ;
45
52
reload ( ) ;
46
53
} )
47
54
. catch ( ( ) => notice ( saveError ) ) ;
@@ -78,13 +85,13 @@ export default function IdentifiersComponent() {
78
85
const renderCards = ( ) => {
79
86
if ( ! data ) return null ;
80
87
const list = [ ] ;
81
- const inactives = data . data . filter ( ( el ) => ( el . active === false ) ) ;
82
- const actives = data . data . filter ( ( el ) => ( el . active !== false ) ) ;
88
+ const inactives = data . data . filter ( ( el ) => el . active === false ) ;
89
+ const actives = data . data . filter ( ( el ) => el . active !== false ) ;
83
90
const orderedList = [ ...actives , ...inactives ] ;
84
91
85
92
if ( data ) {
86
93
orderedList ?. forEach ( ( el ) => {
87
- const inactive = ( el . active === false ) ;
94
+ const inactive = el . active === false ;
88
95
let siretCard = el . value ;
89
96
90
97
if ( el . type === 'siret' ) {
@@ -116,7 +123,7 @@ export default function IdentifiersComponent() {
116
123
if ( el . type !== 'siret' && el . type !== 'cnrs-unit' ) {
117
124
list . push (
118
125
< KeyValueCard
119
- cardKey = { options ?. find ( ( type ) => ( el . type === type . value ) ) ?. label }
126
+ cardKey = { options ?. find ( ( type ) => el . type === type . value ) ?. label }
120
127
cardValue = { el . value }
121
128
className = { `card-${ apiObject } ` }
122
129
copy
0 commit comments