diff --git a/packages/reva-admin-react/src/app/(admin)/certifications-v2/[certificationId]/page.tsx b/packages/reva-admin-react/src/app/(admin)/certifications-v2/[certificationId]/page.tsx index b9395da06..091393c15 100644 --- a/packages/reva-admin-react/src/app/(admin)/certifications-v2/[certificationId]/page.tsx +++ b/packages/reva-admin-react/src/app/(admin)/certifications-v2/[certificationId]/page.tsx @@ -58,16 +58,16 @@ const PageContent = ({ {certification.label}
{certification.degree.label} - {certification.typeDiplome || ""} + {certification.typeDiplome || "Inconnu"} {certification.rncpExpiresAt ? format(certification.rncpExpiresAt, "dd/MM/yyyy") - : ""} + : "Inconnue"} {certification.rncpDeliveryDeadline ? format(certification.rncpDeliveryDeadline, "dd/MM/yyyy") - : ""} + : "Inconnue"}
diff --git a/packages/reva-admin-react/src/app/(admin)/certifications-v2/add-certification/description/page.tsx b/packages/reva-admin-react/src/app/(admin)/certifications-v2/add-certification/description/page.tsx index 09cb1b522..e812e79b0 100644 --- a/packages/reva-admin-react/src/app/(admin)/certifications-v2/add-certification/description/page.tsx +++ b/packages/reva-admin-react/src/app/(admin)/certifications-v2/add-certification/description/page.tsx @@ -100,12 +100,12 @@ export default function CertificationDescriptionPage() { - {certification?.NOMENCLATURE_EUROPE.INTITULE} + {certification?.NOMENCLATURE_EUROPE?.INTITULE || "Inconnu"} {certification.ABREGE ? `${certification.ABREGE.LIBELLE} (${certification.ABREGE.CODE})` - : "Inconnue"} + : "Inconnu"} {certification.DATE_FIN_ENREGISTREMENT @@ -113,12 +113,12 @@ export default function CertificationDescriptionPage() { certification.DATE_FIN_ENREGISTREMENT, "dd/MM/yyyy", ) - : ""} + : "Inconnue"} {certification.DATE_LIMITE_DELIVRANCE ? format(certification.DATE_LIMITE_DELIVRANCE, "dd/MM/yyyy") - : ""} + : "Inconnue"} diff --git a/packages/reva-admin-react/src/app/(admin)/certifications/[certificationId]/_components/CertificationGeneralInformation.tsx b/packages/reva-admin-react/src/app/(admin)/certifications/[certificationId]/_components/CertificationGeneralInformation.tsx index ab5e5c50b..cfb8933d4 100644 --- a/packages/reva-admin-react/src/app/(admin)/certifications/[certificationId]/_components/CertificationGeneralInformation.tsx +++ b/packages/reva-admin-react/src/app/(admin)/certifications/[certificationId]/_components/CertificationGeneralInformation.tsx @@ -36,7 +36,7 @@ export const CertificationGeneralInformation = ({
- {fcCertification.NOMENCLATURE_EUROPE.INTITULE} + {fcCertification.NOMENCLATURE_EUROPE?.INTITULE || "Inconnu"} {fcCertification.ABREGE @@ -44,7 +44,9 @@ export const CertificationGeneralInformation = ({ : "Inconnue"} - {format(fcCertification.DATE_FIN_ENREGISTREMENT, "dd/MM/yyyy")} + {fcCertification.DATE_FIN_ENREGISTREMENT + ? format(fcCertification.DATE_FIN_ENREGISTREMENT, "dd/MM/yyyy") + : "Inconnue"} {fcCertification.DATE_LIMITE_DELIVRANCE diff --git a/packages/reva-api/modules/referential/features/addCertification.ts b/packages/reva-api/modules/referential/features/addCertification.ts index 0af89b53a..4dc1761fd 100644 --- a/packages/reva-api/modules/referential/features/addCertification.ts +++ b/packages/reva-api/modules/referential/features/addCertification.ts @@ -39,6 +39,12 @@ export const addCertification = async (params: { codeRncp: string }) => { : rncpCertification.INTITULE; const availableAt = new Date(); + + if (!rncpCertification.DATE_FIN_ENREGISTREMENT) { + throw new Error( + `La certification avec le code rncp ${codeRncp} n'a pas de date de fin d'enregistrement`, + ); + } const expiresAt = new Date(rncpCertification.DATE_FIN_ENREGISTREMENT); const certification = await prismaClient.certification.create({ @@ -88,7 +94,7 @@ const getLevelFromRNCPCertification = ( ): number => { try { const strLevel = - certification.NOMENCLATURE_EUROPE.INTITULE.split(" ").reverse()[0]; + certification.NOMENCLATURE_EUROPE?.INTITULE.split(" ").reverse()[0] || ""; const level = parseInt(strLevel, 10); return level; } catch { diff --git a/packages/reva-api/modules/referential/features/updateCertificationWithRncpFields.ts b/packages/reva-api/modules/referential/features/updateCertificationWithRncpFields.ts index c206b3a2b..d3c56c056 100644 --- a/packages/reva-api/modules/referential/features/updateCertificationWithRncpFields.ts +++ b/packages/reva-api/modules/referential/features/updateCertificationWithRncpFields.ts @@ -31,6 +31,12 @@ export const updateCertificationWithRncpFields = async (params: { : rncpCertification.INTITULE; const availableAt = new Date(); + + if (!rncpCertification.DATE_FIN_ENREGISTREMENT) { + throw new Error( + `La certification avec le code rncp ${codeRncp} n'a pas de date de fin d'enregistrement`, + ); + } const expiresAt = new Date(rncpCertification.DATE_FIN_ENREGISTREMENT); // Update certification from based on RNCP @@ -58,7 +64,7 @@ const getLevelFromRNCPCertification = ( ): number => { try { const strLevel = - certification.NOMENCLATURE_EUROPE.INTITULE.split(" ").reverse()[0]; + certification.NOMENCLATURE_EUROPE?.INTITULE.split(" ").reverse()[0] || ""; const level = parseInt(strLevel, 10); return level; } catch { diff --git a/packages/reva-api/modules/referential/referential.graphql b/packages/reva-api/modules/referential/referential.graphql index 8f1d96770..85a14361a 100644 --- a/packages/reva-api/modules/referential/referential.graphql +++ b/packages/reva-api/modules/referential/referential.graphql @@ -152,8 +152,8 @@ type FCCertification { NUMERO_FICHE: String! INTITULE: String! ABREGE: FCAbrege - NOMENCLATURE_EUROPE: FCNomenclatureEurope! - DATE_FIN_ENREGISTREMENT: Timestamp! + NOMENCLATURE_EUROPE: FCNomenclatureEurope + DATE_FIN_ENREGISTREMENT: Timestamp DATE_LIMITE_DELIVRANCE: Timestamp BLOCS_COMPETENCES: [BlocCompetence!]! FORMACODES: [FCFormacode!]! diff --git a/packages/reva-api/modules/referential/rncp/referential.ts b/packages/reva-api/modules/referential/rncp/referential.ts index 9ff545028..fdc179d93 100644 --- a/packages/reva-api/modules/referential/rncp/referential.ts +++ b/packages/reva-api/modules/referential/rncp/referential.ts @@ -43,11 +43,11 @@ export type RNCPCertification = { CODE: string; LIBELLE: string; }; - NOMENCLATURE_EUROPE: { + NOMENCLATURE_EUROPE?: { NIVEAU: string; INTITULE: string; }; - DATE_FIN_ENREGISTREMENT: number; + DATE_FIN_ENREGISTREMENT?: number; DATE_LIMITE_DELIVRANCE?: number; BLOCS_COMPETENCES: { CODE: string; @@ -113,9 +113,11 @@ export class RNCPReferential { (acc, value) => { const certification = mapToRNCPCertification(value); if (certification) { - return [...acc, certification]; + throw new Error( + `La certification avec le code rncp ${value?.NUMERO_FICHE} n'a pas pu être parsée. Veuillez contacter le support technique.`, + ); } - return acc; + return [...acc, certification]; }, [] as RNCPCertification[], ); @@ -256,11 +258,15 @@ function mapToRNCPCertification(data: any): RNCPCertification | undefined { LIBELLE: data.ABREGE.LIBELLE, } : undefined, - NOMENCLATURE_EUROPE: { - NIVEAU: data.NOMENCLATURE_EUROPE.NIVEAU, - INTITULE: data.NOMENCLATURE_EUROPE.INTITULE, - }, - DATE_FIN_ENREGISTREMENT: getDateFromString(data.DATE_FIN_ENREGISTREMENT), + NOMENCLATURE_EUROPE: data.NOMENCLATURE_EUROPE + ? { + NIVEAU: data.NOMENCLATURE_EUROPE.NIVEAU, + INTITULE: data.NOMENCLATURE_EUROPE.INTITULE, + } + : undefined, + DATE_FIN_ENREGISTREMENT: data.DATE_FIN_ENREGISTREMENT + ? getDateFromString(data.DATE_FIN_ENREGISTREMENT) + : undefined, DATE_LIMITE_DELIVRANCE: data.DATE_LIMITE_DELIVRANCE ? getDateFromString(data.DATE_LIMITE_DELIVRANCE) : undefined,