Skip to content

Commit

Permalink
fix(identifiers): update link for rna and regroup siret card into one…
Browse files Browse the repository at this point in the history
… card
  • Loading branch information
Mihoub2 committed Jan 29, 2024
1 parent 7a261f5 commit 270985d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 39 deletions.
77 changes: 39 additions & 38 deletions src/components/blocs/identifiers/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Modal, ModalContent, ModalTitle } from '@dataesr/react-dsfr';
import { Col, Modal, ModalContent, ModalTitle, Text } from '@dataesr/react-dsfr';
import { useState } from 'react';

import IdentifierForm from '../../forms/identifier';
Expand All @@ -24,6 +24,7 @@ import {
saveSuccess,
} from '../../../utils/notice-contents';
import getLink from '../../../utils/get-links';
import CopyButton from '../../copy/copy-button';

export default function IdentifiersComponent() {
const { notice } = useNotice();
Expand Down Expand Up @@ -84,73 +85,73 @@ export default function IdentifiersComponent() {
if (data) {
orderedList?.forEach((el) => {
const inactive = (el.active === false);
list.push(
<KeyValueCard
cardKey={options?.find((type) => (el.type === type.value))?.label}
cardValue={el.value}
className={`card-${apiObject}`}
copy
icon="ri-fingerprint-2-line"
key={el.id}
onEdit={() => onOpenModalHandler(el)}
linkTo={getLink(el)}
inactive={inactive}
/>,
);
if (el.type === 'cnrs-unit') {
let siretCard = el.value;

if (el.type === 'siret') {
const sireneValue = getTvaIntraFromSiren(el.value);

siretCard = (
<Col>
<Text>
Siret :
{' '}
{el.value}
{' '}
<CopyButton copyText={el.value} size="sm" />
<br />
Siren :
{' '}
{el.value.substring(0, 9)}
{' '}
<CopyButton copyText={el.value.substring(0, 9)} size="sm" />
<br />
Numéro de TVA :
{' '}
{sireneValue}
<CopyButton copyText={sireneValue} size="sm" />
</Text>
</Col>
);
}
if (el.type !== 'siret') {
list.push(
<KeyValueCard
cardKey="Voir dans GraFiLabo"
cardKey={options?.find((type) => (el.type === type.value))?.label}
cardValue={el.value}
className={`card-${apiObject}`}
copy
icon="ri-fingerprint-2-line"
key={el.id}
onEdit={() => onOpenModalHandler(el)}
linkTo={getLink({ ...el, type: 'cnrs-grafilabo' })}
linkTo={getLink(el)}
inactive={inactive}
/>,
);
}
if (el.type === 'wikidata') {
if (el.type === 'cnrs-unit') {
list.push(
<KeyValueCard
cardKey="Wikidata Fichier JSON"
cardKey="Voir dans GraFiLabo"
cardValue={el.value}
className={`card-${apiObject}`}
copy
icon="ri-fingerprint-2-line"
key={el.id}
onEdit={() => onOpenModalHandler(el)}
linkTo={getLink({ ...el, type: 'wikidata_json' })}
linkTo={getLink({ ...el, type: 'cnrs-grafilabo' })}
inactive={inactive}
/>,
);
}
if (el.type === 'siret') {
const siren = el.value.substring(0, 9);
list.push(
<KeyValueCard
cardKey="Siren"
cardValue={siren}
cardKey="SIRENE - Siret"
cardValue={siretCard}
className={`card-${apiObject}`}
copy
icon="ri-fingerprint-2-line"
key={el.id}
onEdit={() => onOpenModalHandler(el)}
linkTo={getLink({ ...el, type: 'siren' })}
inactive={inactive}
/>,
);
list.push(
<KeyValueCard
cardKey="Numéro de TVA intracommunautaire"
cardValue={getTvaIntraFromSiren(siren)}
className={`card-${apiObject}`}
copy
icon="ri-fingerprint-2-line"
key={el.id}
onEdit={() => onOpenModalHandler(el)}
linkTo={getLink({ ...el, type: 'siret' })}
inactive={inactive}
/>,
);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/get-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function getLink(el) {
linkTo = `http://www.sudoc.abes.fr//DB=2.2/SET=1/TTL=3/CMD?ACT=SRCHA&IKT=8888&SRT=RLV&TRM=${el.value}`;
break;
case 'rna':
linkTo = `https://entreprise.data.gouv.fr/etablissement/${el.value}`;
linkTo = `https://www.data-asso.fr/annuaire/association/${el.value}?docFields=documentsDac,documentsRna`;
break;
case 'rnsr':
linkTo = `https://appliweb.dgri.education.fr/rnsr/PresenteStruct.jsp?numNatStruct=${el.value}&PUBLIC=OK`;
Expand Down

0 comments on commit 270985d

Please sign in to comment.