diff --git a/clients/recherche-entreprise/index.ts b/clients/recherche-entreprise/index.ts
index 3d1087033..0265320aa 100644
--- a/clients/recherche-entreprise/index.ts
+++ b/clients/recherche-entreprise/index.ts
@@ -274,7 +274,9 @@ const mapToUniteLegale = (result: IResult, pageEtablissements: number) => {
dateMiseAJourInsee: date_mise_a_jour_insee || '',
dateMiseAJourInpi: date_mise_a_jour_rne || '',
dateFermeture: date_fermeture ?? '',
- listeIdcc: liste_idcc || [],
+ listeIdcc: (liste_idcc || []).map((idcc) => {
+ return { idcc, title: '' };
+ }),
};
};
diff --git a/clients/recherche-entreprise/mapToDomain/index.ts b/clients/recherche-entreprise/mapToDomain/index.ts
index 505b8f63d..3186c8795 100644
--- a/clients/recherche-entreprise/mapToDomain/index.ts
+++ b/clients/recherche-entreprise/mapToDomain/index.ts
@@ -187,10 +187,13 @@ export const mapToEtablissement = (
estEntrepreneurIndividuel,
idFiness: liste_finess || [],
idBio: liste_id_bio || [],
- idcc: liste_idcc || [],
idOrganismeFormation: liste_id_organisme_formation || [],
idRge: liste_rge || [],
idUai: liste_uai || [],
},
+ listeIdcc: (liste_idcc || []).map((idcc) => {
+ // as etablissement will undergo a refacto, we prefer a simpler implem with no title
+ return { idcc, title: '' };
+ }),
};
};
diff --git a/components/badges-section/convention-collectives/index.tsx b/components/badges-section/convention-collectives/index.tsx
index 94652499a..d79730e87 100644
--- a/components/badges-section/convention-collectives/index.tsx
+++ b/components/badges-section/convention-collectives/index.tsx
@@ -1,24 +1,33 @@
-import React from 'react';
+import InformationTooltip from '#components-ui/information-tooltip';
import { Tag } from '#components-ui/tag';
import { Siren } from '#utils/helpers';
+import React from 'react';
+
+const TagCC = ({ siren, idcc }: { siren: Siren; idcc: string }) => (
+
+ IDCC {idcc}
+
+);
export const ConventionCollectivesBadgesSection: React.FC<{
- conventionCollectives: string[];
siren: Siren;
-}> = ({ conventionCollectives, siren }) =>
+ conventionCollectives: { idcc: string; title: string }[];
+}> = ({ siren, conventionCollectives }) =>
conventionCollectives.length > 0 ? (
- conventionCollectives.map((idcc) => (
+ conventionCollectives.map(({ idcc, title }) => (
- {
-
- IDCC {idcc}
-
- }
+ {title ? (
+
+
+
+ ) : (
+
+ )}
))
) : (
diff --git a/components/etablissement-section/index.tsx b/components/etablissement-section/index.tsx
index 7e549894c..7733b3429 100644
--- a/components/etablissement-section/index.tsx
+++ b/components/etablissement-section/index.tsx
@@ -134,13 +134,13 @@ const EtablissementSection: React.FC = ({
? [['Date de fermeture', formatDate(etablissement.dateFermeture || '')]]
: []),
['',
],
- ...(etablissement.complements.idcc
+ ...(etablissement.listeIdcc
? [
[
'Convention collective de l’établissement',
[
,
],
diff --git a/models/conventions-collectives/index.ts b/models/conventions-collectives/index.ts
index 235fd28f2..13dab4397 100644
--- a/models/conventions-collectives/index.ts
+++ b/models/conventions-collectives/index.ts
@@ -26,6 +26,36 @@ export type ICCWithMetadata = {
unknown: boolean;
};
+/**
+ * Get title from metadata for a single idcc
+ * @param siren
+ * @param idcc
+ * @returns
+ */
+export const getIdccTitle = async (siren: Siren, idcc: string) => {
+ try {
+ const metadata = await clientIdccMetadata(idcc);
+ return { idcc, title: metadata.title || '' };
+ } catch (e: any) {
+ logErrorInSentry(
+ new FetchRessourceException({
+ cause: e,
+ ressource: 'Convention Collective',
+ context: {
+ siren,
+ },
+ })
+ );
+ // when metadata fails we intentionnally ignore failure
+ return { idcc, title: '' };
+ }
+};
+
+/**
+ * Get all idcc and their metadata for a given siren
+ * @param siren
+ * @returns
+ */
export const getAllIdccWithMetadata = async (
siren: Siren
): Promise => {
diff --git a/models/core/types.ts b/models/core/types.ts
index 0e596c509..4fef303c4 100644
--- a/models/core/types.ts
+++ b/models/core/types.ts
@@ -42,6 +42,7 @@ export interface IEtablissement {
latitude: string;
longitude: string;
complements: IEtablissementComplements;
+ listeIdcc: { idcc: string; title: string }[];
}
export interface IEtablissementWithUniteLegale {
@@ -78,6 +79,7 @@ export const createDefaultEtablissement = (): IEtablissement => {
latitude: '',
longitude: '',
complements: createDefaultEtablissementComplements(),
+ listeIdcc: [],
};
};
@@ -118,7 +120,7 @@ export interface IUniteLegale extends IEtablissementsList {
colter: {
codeColter: string | null;
};
- listeIdcc: string[];
+ listeIdcc: { idcc: string; title: string }[];
}
export const createDefaultUniteLegale = (siren: Siren): IUniteLegale => {
@@ -220,7 +222,6 @@ export interface IEtablissementComplements {
estEntrepreneurIndividuel: boolean;
idFiness: string[];
idBio: string[];
- idcc: string[];
idOrganismeFormation: string[];
idRge: string[];
idUai: string[];
@@ -232,7 +233,6 @@ export const createDefaultEtablissementComplements =
estEntrepreneurIndividuel: false,
idFiness: [],
idBio: [],
- idcc: [],
idOrganismeFormation: [],
idRge: [],
idUai: [],
diff --git a/models/core/unite-legale.ts b/models/core/unite-legale.ts
index 59e650a61..2c1bcf3c0 100644
--- a/models/core/unite-legale.ts
+++ b/models/core/unite-legale.ts
@@ -7,6 +7,7 @@ import {
} from '#clients/exceptions';
import { clientUniteLegaleRechercheEntreprise } from '#clients/recherche-entreprise/siren';
import { clientUniteLegaleInsee } from '#clients/sirene-insee/siren';
+import { getIdccTitle } from '#models/conventions-collectives';
import { createEtablissementsList } from '#models/core/etablissements-list';
import { IETATADMINSTRATIF, estActif } from '#models/core/etat-administratif';
import { Siren, isLuhnValid, verifySiren } from '#utils/helpers';
@@ -101,6 +102,13 @@ class UniteLegaleBuilder {
IETATADMINSTRATIF.ACTIF_ZERO_ETABLISSEMENT;
}
+ // idcc
+ uniteLegale.listeIdcc = await Promise.all(
+ uniteLegale.listeIdcc.map(async ({ idcc }) => {
+ return await getIdccTitle(uniteLegale.siren, idcc);
+ })
+ );
+
return uniteLegale;
};