Skip to content

Commit

Permalink
feat: use anciens sieges from recherche entreprise
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierJp committed Aug 13, 2024
1 parent 9b72ab7 commit bc6e44b
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 45 deletions.
5 changes: 1 addition & 4 deletions app/(header-default)/entreprise/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ export default async function UniteLegalePage(props: AppRouterProps) {
session={session}
/>
)}
<EtablissementListeSection
uniteLegale={uniteLegale}
session={session}
/>
<EtablissementListeSection uniteLegale={uniteLegale} />
</>
)}
</div>
Expand Down
2 changes: 2 additions & 0 deletions clients/recherche-entreprise/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ const mapToEtablissement = (
liste_enseignes,
etat_administratif,
est_siege = false,
ancien_siege = false,
nom_commercial = '',
activite_principale = '',
date_creation = '',
Expand Down Expand Up @@ -382,6 +383,7 @@ const mapToEtablissement = (
latitude,
longitude,
estSiege: est_siege,
ancienSiege: ancien_siege,
etatAdministratif,
statutDiffusion: statuDiffusionFromStatutDiffusionInsee(
statut_diffusion_etablissement || 'O',
Expand Down
1 change: 1 addition & 0 deletions clients/recherche-entreprise/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export type IDirigeant = {
};

export type IEtablissementCore = {
ancien_siege: boolean;
activite_principale: string;
adresse: string;
commune: string;
Expand Down
2 changes: 1 addition & 1 deletion components/etablissement-description/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const EtablissementDescription: React.FC<IProps> = ({
C’est
{etablissement.estSiege ? (
<strong> le siège social</strong>
) : uniteLegale.allSiegesSiret.indexOf(etablissement.siret) > -1 ? (
) : etablissement.ancienSiege ? (
<> un ancien siège social</>
) : (
<> un établissement secondaire</>
Expand Down
56 changes: 20 additions & 36 deletions components/etablissement-liste-section/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ import { EAdministration } from '#models/administrations/EAdministration';
import constants from '#models/constants';
import { estNonDiffusibleStrict } from '#models/core/diffusion';
import { IEtablissement, IUniteLegale } from '#models/core/types';
import { ISession } from '#models/user/session';
import { Siret, formatDate, formatSiret } from '#utils/helpers';
import { formatDate, formatSiret } from '#utils/helpers';

const EtablissementTable: React.FC<{
label?: string;
etablissements: IEtablissement[];
sieges: Siret[];
session: ISession | null;
}> = ({ label, etablissements, sieges = [], session }) => {
}> = ({ label, etablissements }) => {
const plural = etablissements.length > 1 ? 's' : '';
return (
<>
Expand Down Expand Up @@ -63,9 +60,11 @@ const EtablissementTable: React.FC<{
)}
<>{etablissement.adresse}</>
</span>
{etablissement.estSiege && <Tag color="info">siège social</Tag>}
{sieges.indexOf(etablissement.siret) > 0 &&
!etablissement.estSiege && <Tag>ancien siège social</Tag>}
{etablissement.estSiege ? (
<Tag color="info">siège social</Tag>
) : etablissement.ancienSiege ? (
<Tag>ancien siège social</Tag>
) : null}
</>
)}
</>,
Expand All @@ -87,8 +86,7 @@ const EtablissementTable: React.FC<{

const EtablissementListeSection: React.FC<{
uniteLegale: IUniteLegale;
session: ISession | null;
}> = ({ uniteLegale, session }) => {
}> = ({ uniteLegale }) => {
const {
usePagination,
nombreEtablissements,
Expand Down Expand Up @@ -127,8 +125,6 @@ const EtablissementListeSection: React.FC<{
<>
<EtablissementTable
etablissements={uniteLegale.etablissements.all}
sieges={uniteLegale.allSiegesSiret}
session={session}
/>
<PageCounter
currentPage={currentEtablissementPage || 1}
Expand All @@ -139,34 +135,22 @@ const EtablissementListeSection: React.FC<{
) : (
<>
{uniteLegale.etablissements.open.length > 0 && (
<>
<EtablissementTable
label="actif"
etablissements={uniteLegale.etablissements.open}
sieges={uniteLegale.allSiegesSiret}
session={session}
/>
</>
<EtablissementTable
label="actif"
etablissements={uniteLegale.etablissements.open}
/>
)}
{uniteLegale.etablissements.unknown.length > 0 && (
<>
<EtablissementTable
label="non-diffusible"
etablissements={uniteLegale.etablissements.unknown}
sieges={uniteLegale.allSiegesSiret}
session={session}
/>
</>
<EtablissementTable
label="non-diffusible"
etablissements={uniteLegale.etablissements.unknown}
/>
)}
{uniteLegale.etablissements.closed.length > 0 && (
<>
<EtablissementTable
label="fermé"
etablissements={uniteLegale.etablissements.closed}
sieges={uniteLegale.allSiegesSiret}
session={session}
/>
</>
<EtablissementTable
label="fermé"
etablissements={uniteLegale.etablissements.closed}
/>
)}
</>
)}
Expand Down
3 changes: 1 addition & 2 deletions components/etablissement-section/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ const EtablissementSection: React.FC<IProps> = ({
<>
{etablissement.estSiege ? (
<Tag color="info">siège social</Tag>
) : uniteLegale.allSiegesSiret.indexOf(etablissement.siret) >
-1 ? (
) : etablissement.ancienSiege ? (
<Tag>ancien siège social</Tag>
) : (
<Tag>secondaire</Tag>
Expand Down
3 changes: 1 addition & 2 deletions components/title-section/etablissement/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ const TitleEtablissementWithDenomination: React.FC<{
siège social
</Tag>
</>
) : uniteLegale.allSiegesSiret.indexOf(etablissement.siret) > -1 &&
!etablissement.estSiege ? (
) : etablissement.ancienSiege ? (
<>
un<Tag size="small">ancien siège social</Tag>
</>
Expand Down
1 change: 1 addition & 0 deletions models/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface IEtablissement {
etatAdministratif: IETATADMINSTRATIF;
statutDiffusion: ISTATUTDIFFUSION;
estSiege: boolean;
ancienSiege: boolean;
dateCreation: string;
dateDerniereMiseAJour: string;
dateMiseAJourInsee: string;
Expand Down

0 comments on commit bc6e44b

Please sign in to comment.