Skip to content

Commit

Permalink
Merge branch 'main' into 1068-kbis
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierJp committed May 31, 2024
2 parents 112e699 + ab9da9b commit 3fe28f1
Show file tree
Hide file tree
Showing 42 changed files with 607 additions and 327 deletions.
11 changes: 9 additions & 2 deletions app/(header-default)/dirigeants/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import extractParamsAppRouter, {
AppRouterProps,
} from '#utils/server-side-helper/app/extract-params';
import getSession from '#utils/server-side-helper/app/get-session';
import ResponsableSection from 'app/(header-default)/dirigeants/_component/sections/responsables-service-public';
import ResponsableSection from 'app/(header-default)/dirigeants/_component/sections/service-public-responsables';
import { DirigeantInformation } from '../_component/sections';
import SubServicesSection from '../_component/sections/service-public-subservices';

export const generateMetadata = async (
props: AppRouterProps
Expand Down Expand Up @@ -56,7 +57,13 @@ const DirigeantsPage = async (props: AppRouterProps) => {
session={session}
/>
{servicePublic ? (
<ResponsableSection servicePublic={servicePublic} />
<>
<ResponsableSection servicePublic={servicePublic} />
<SubServicesSection
servicePublic={servicePublic}
uniteLegale={uniteLegale}
/>
</>
) : (
!isBot && (
<Suspense fallback={<PageLoader />}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DonneesPriveesSection } from '#components/donnees-privees-section';
import { estDiffusible } from '#models/core/statut-diffusion';
import { IUniteLegale } from '#models/core/types';
import { getMandatairesRCS } from '#models/espace-agent/mandataires-rcs';
import getImmatriculationRNE from '#models/immatriculation/rne';
import { getImmatriculationRNE } from '#models/immatriculation/rne';
import { EScope, hasRights } from '#models/user/rights';
import { ISession } from '#models/user/session';
import BeneficiairesSection from './beneficiaires';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import { IAPINotRespondingError } from '#models/api-not-responding';
import { IServicePublic } from '#models/service-public';

type IProps = { servicePublic: IServicePublic | IAPINotRespondingError };

export default function ResponsableSection({ servicePublic }: IProps) {
return (
<DataSection
id="responsables-service-public"
title={`Dirigeants`}
title={`Responsable(s)`}
sources={[EAdministration.DILA]}
notFoundInfo={<NotFoundInfo />}
data={servicePublic}
Expand All @@ -20,15 +21,15 @@ export default function ResponsableSection({ servicePublic }: IProps) {
<>
{!servicePublic.affectationPersonne ? (
<p>
Ce service public n’a pas d’équipe dirigeante enregistrée auprès
de la <DILA />.
Ce service public n’a pas de responsable enregistré auprès de la{' '}
<DILA />.
</p>
) : (
<>
<p>
Ce service public possède{' '}
{servicePublic.affectationPersonne.length} dirigeant(es)
enregistré(es) auprès de la <DILA />
{servicePublic.affectationPersonne.length} responsable(s)
enregistré(s) auprès de la <DILA />
{servicePublic.liens.annuaireServicePublic && (
<>
{' '}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
'use client';

import NonRenseigne from '#components/non-renseigne';
import { DataSectionClient } from '#components/section/data-section';
import { FullTable } from '#components/table/full';
import { EAdministration } from '#models/administrations/EAdministration';
import {
IAPINotRespondingError,
isAPINotResponding,
} from '#models/api-not-responding';
import { IUniteLegale } from '#models/core/types';
import { IServicePublic } from '#models/service-public';
import { useFetchServicePublicSubServices } from 'hooks/fetch/service-public-subservices';

function SubServicesDataSection({
servicePublic,
uniteLegale,
}: {
servicePublic: IServicePublic;
uniteLegale: IUniteLegale;
}) {
const subServices = useFetchServicePublicSubServices(
servicePublic,
uniteLegale
);

return (
<DataSectionClient
id="subservices-service-public"
title="Département(s)"
sources={[EAdministration.DILA]}
data={subServices}
>
{(subServices) => (
<>
<p>
Ce service public se compose de {subServices.length} départements :
</p>
<FullTable
head={['Nom du département', 'Responsable(s)']}
body={subServices.map((service) => {
return [
service.urlServicePublic ? (
<a
target="_blank"
rel="noopener noreferrer"
aria-label={`Voir ${service.nom}, nouvelle fenêtre`}
href={service.urlServicePublic}
>
{service.nom}
</a>
) : (
service.nom
),
service.affectationPersonne?.length === 0 ? (
<NonRenseigne />
) : service?.affectationPersonne &&
service?.affectationPersonne.length > 0 ? (
service?.affectationPersonne.map((personne, index) => (
<>
{index !== 0 && ', '}
<b>{personne.nom}</b> {personne.fonction}
</>
))
) : (
<NonRenseigne />
),
];
})}
/>
</>
)}
</DataSectionClient>
);
}

export default function SubServicesSection({
servicePublic,
uniteLegale,
}: {
servicePublic: IServicePublic | IAPINotRespondingError;
uniteLegale: IUniteLegale;
}) {
if (
isAPINotResponding(servicePublic) ||
servicePublic.subServicesId?.length === 0
) {
return null;
}

return (
<SubServicesDataSection
servicePublic={servicePublic}
uniteLegale={uniteLegale}
/>
);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IUniteLegale } from '#models/core/types';
import getImmatriculationRNE from '#models/immatriculation/rne';
import { getImmatriculationRNE } from '#models/immatriculation/rne';
import { ISession } from '#models/user/session';
import { IJustificatifs, ImmatriculationsSection } from './container';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Suspense } from 'react';
import { OpqibiSection } from '#components/espace-agent-components/certifications/opqibi-section';
import { QualibatSection } from '#components/espace-agent-components/certifications/qualibat-section';
import { QualifelecSection } from '#components/espace-agent-components/certifications/qualifelec-section';
import {
IAPINotRespondingError,
Expand Down Expand Up @@ -37,7 +36,8 @@ export async function ProtectedCertificats({
<NoCertificatsWarning certificats={[opqibi, qualifelec, qualibat]} />
</Suspense>
)}
<QualibatSection qualibat={qualibat} />
{/* Qualibat API is down. When it's back up, uncomment this line
<QualibatSection qualibat={qualibat} /> */}
<QualifelecSection qualifelec={qualifelec} />
<OpqibiSection opqibi={opqibi} />
</>
Expand Down
1 change: 0 additions & 1 deletion app/(header-default)/labels-certificats/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ const LabelsAndCertificatsPage = async (props: AppRouterProps) => {
{estOrganismeFormation && (
<OrganismeDeFormationSection
organismesDeFormation={organismesDeFormation}
uniteLegale={uniteLegale}
/>
)}
{egaproRenseignee && <EgaproSection egapro={egapro} />}
Expand Down
38 changes: 0 additions & 38 deletions app/api/data-fetching/espace-agent/_helper/index.ts

This file was deleted.

26 changes: 0 additions & 26 deletions app/api/data-fetching/espace-agent/documents/[slug]/route.ts

This file was deleted.

4 changes: 2 additions & 2 deletions app/global-error.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use client';

import NextError from 'next/error';
import { useLogFatalErrorAppClient } from 'hooks';
import { useLog500ErrorAppClient } from 'hooks';

export default function GlobalError({
error,
}: {
error: Error & { digest?: string };
}) {
useLogFatalErrorAppClient(error);
useLog500ErrorAppClient(error);
return (
<html>
<body>
Expand Down
39 changes: 39 additions & 0 deletions clients/open-data-soft/clients/annuaire-service-public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ interface IServicePublicRecord {
telephone: string;
type_organisme: string;
url_service_public: string;
hierarchie: string;
}

type IServices = { type_hierarchie: string; service: string };

type IAffectationRecord = {
personne: {
prenom: string;
Expand Down Expand Up @@ -75,6 +78,20 @@ const clientAnnuaireServicePublicByName = async (
};
};

const clientAnnuaireServicePublicByIds = async (
ids: string[]
): Promise<IServicePublic[]> => {
const query = `id="${ids.join('" OR id="')}"`;
const useCache = false;
let response = await queryAnnuaireServicePublic(query);

if (!response.records.length) {
throw new HttpNotFound(`Ids = ${ids.join(', ')}`);
}

return response.records.map(mapToDomainObject);
};

const clientAnnuaireServicePublicBySiret = async (
siret: Siret
): Promise<IServicePublic> => {
Expand Down Expand Up @@ -107,9 +124,26 @@ const mapToDomainObject = (
typeOrganisme:
(record.type_organisme as IServicePublic['typeOrganisme']) || null,
nom: mapToNom(record),
subServicesId: mapToServicesId(record.hierarchie),
};
};

/**
* List of sub services
* @param hierarchieSerialized
* @returns
*/
function mapToServicesId(hierarchieSerialized: string): string[] {
const hierarchie = JSON.parse(
hierarchieSerialized || 'null'
) as Array<IServices> | null;

if (!hierarchie || !hierarchie.length) {
return [];
}
return hierarchie.map((service) => service.service);
}

type IAffectationPersonne = IServicePublic['affectationPersonne'];
function mapToAffectationPersonne(
affectationRecord: string
Expand Down Expand Up @@ -232,6 +266,10 @@ function mapToLiens(record: IServicePublicRecord) {
return liens;
}

const stubbedClientAnnuaireServicePublicByIds = stubClient({
clientAnnuaireServicePublicByIds,
});

const stubbedClientAnnuaireServicePublicBySiret = stubClient({
clientAnnuaireServicePublicBySiret,
});
Expand All @@ -240,6 +278,7 @@ const stubbedClientAnnuaireServicePublicByName = stubClient({
clientAnnuaireServicePublicByName,
});
export {
stubbedClientAnnuaireServicePublicByIds as clientAnnuaireServicePublicByIds,
stubbedClientAnnuaireServicePublicByName as clientAnnuaireServicePublicByName,
stubbedClientAnnuaireServicePublicBySiret as clientAnnuaireServicePublicBySiret,
};
3 changes: 3 additions & 0 deletions clients/open-data-soft/clients/qualiopi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const clientOrganismeFormation = async (
const fields = response.records as IOrganismesFormationRecord[];
return {
records: fields.map(mapToDomainObject),
qualiopiCertified: !!fields.find(
(f) => (f?.certifications || []).length > 0
),
lastModified: response.lastModified,
};
};
Expand Down
1 change: 0 additions & 1 deletion clients/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const routes = {
api: {
rne: {
documents: {
list: '/api/data-fetching/espace-agent/documents/',
download: '/api/download/espace-agent/documents/',
},
},
Expand Down
Loading

0 comments on commit 3fe28f1

Please sign in to comment.