Skip to content

Commit

Permalink
feat: display 10 establishment
Browse files Browse the repository at this point in the history
  • Loading branch information
ImenOuidou committed Oct 25, 2023
1 parent 6e87332 commit 982341c
Show file tree
Hide file tree
Showing 13 changed files with 186 additions and 218 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const AccidentTravail = ({ entreprise: { siren } }) => {
</tr>
</thead>
<tbody>
{accidents.map((data) => {
const etab = data.etablissement;
{accidents.map((accidnt) => {
const etab = accidnt.etablissement;
const isEtablissementActive = isActive(etab);
const stateClass = isEtablissementActive
? "icon--success"
Expand All @@ -68,14 +68,14 @@ const AccidentTravail = ({ entreprise: { siren } }) => {
? "ouvert"
: "fermé";
return (
<tr key={getSiret(data.etablissement)}>
<tr key={getSiret(accidnt.etablissement)}>
<td>
{" "}
<SeeDetailsLink
link={`/establishment/${getSiret(
data.etablissement
accidnt.etablissement
)}/#work-accidents`}
text={getSiret(data.etablissement)}
text={getSiret(accidnt.etablissement)}
/>
</td>
<td className="table-cell--center-cell">
Expand All @@ -87,9 +87,9 @@ const AccidentTravail = ({ entreprise: { siren } }) => {
/>
)}
</td>
<td>{getCity(data.etablissement)}</td>
<td>{getCity(accidnt.etablissement)}</td>
<td className="th table-cell--center-cell">
{data.total}
{accidnt.total}
</td>
</tr>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ export const PsiSiretTable = ({ psi, year, isVisiblePsiTable }) => {
</tr>
</thead>
<tbody>
{psi.map((psi) => {
const etab = psi.etablissement;
{psi.map((psiObj) => {
const etab = psiObj.etablissement;
const isEtablissementActive = isActive(etab);
const stateClass = isEtablissementActive
? "icon--success"
: "icon--danger";
const stateText = isEtablissementActive ? "ouvert" : "fermé";
return (
<tr key={psi.siret}>
<tr key={psiObj.siret}>
<td className="table-cell--nowrap">
<SeeDetailsLink
text={formatSiret(psi.siret)}
link={`/establishment/${psi.siret}/#psi`}
text={formatSiret(psiObj.siret)}
link={`/establishment/${psiObj.siret}/#psi`}
/>
</td>

Expand All @@ -58,7 +58,7 @@ export const PsiSiretTable = ({ psi, year, isVisiblePsiTable }) => {
)}
</td>
<td className="th table-cell--center-cell">
{getCity(psi.etablissement)}
{getCity(psiObj.etablissement)}
</td>
</tr>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,5 @@
tr {
background-color: #f6f6f6 !important;
}
tr {
background-color: #f6f6f6 !important;

background-color: $white-smoke;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React from "react";

import { renderIfSiret } from "../../../../../helpers/hoc/renderIfSiret";
import { formatSiren } from "../../../../../helpers/utils";
// import { formatSiret } from "../../../../../helpers/utils";
import {
getNafCode,
getNafLabel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,78 @@ const ListEstablishment = () => {
setCurrentPage(page);
}
};
const renderTableBody = () => {
const data =
etablissementsCount > rowsPerPage
? etablissements?.slice(startIndex, endIndex)
: etablissements;

return data?.map((etablissement) => {
const isEtablissementActive = isActive(etablissement);
const stateClass = isEtablissementActive
? "icon--success"
: "icon--danger";
const stateText = isEtablissementActive ? "ouvert" : "fermé";
return (
<tr
className="at__body__tr"
key={etablissement?.siret}
onClick={() => history.push(`/establishment/${etablissement?.siret}`)}
>
<td>
<Link
to={`/establishment/${etablissement?.siret}`}
className="establishment__siret_link"
>
<Value value={formatSiret(etablissement?.siret)} />
</Link>
</td>
<td>
<BadgeWithIcon isTableBadge text={stateText} state={stateClass} />
</td>

<td>
<Value
value={joinNoFalsy(
[
etablissement?.codepostaletablissement,
etablissement?.libellecommuneetablissement,
],
" - "
)}
/>
</td>
<td>
<Value
value={
etablissement?.trancheeffectifsetablissement !== "-" &&
etablissement?.trancheeffectifsetablissement !== "NN" &&
etablissement?.trancheeffectifsetablissement !== "SP"
? isActiveEstablishment(
etablissement?.etatadministratifetablissement
)
? staffSizeRanges[
etablissement?.trancheeffectifsetablissement
]
: "0 salarié"
: staffSizeRanges[
etablissement?.trancheeffectifsetablissement
]
}
/>
</td>
<td>
<Value value={etablissement?.etb_raisonsociale} />
</td>
<td>{`${etablissement?.activiteprincipaleetablissement || ""} - ${
getLibelletFromCodeNaf(
etablissement?.activiteprincipaleetablissement
) || ""
}`}</td>
</tr>
);
});
};

return (
<section id="autres-etablissements" className="data-sheet__bloc_section ">
Expand All @@ -78,96 +150,9 @@ const ListEstablishment = () => {
<th>Activité</th>
</tr>
</thead>
<tbody>
{etablissements
?.slice(startIndex, endIndex)
?.map((etablissement) => {
const isEtablissementActive = isActive(etablissement);
const stateClass = isEtablissementActive
? "icon--success"
: "icon--danger";
const stateText = isEtablissementActive
? "ouvert"
: "fermé";
return (
<tr
className="at__body__tr"
key={etablissement?.siret}
onClick={() =>
history.push(
`/establishment/${etablissement?.siret}`
)
}
>
<td>
<Link
to={`/establishment/${etablissement?.siret}`}
className="establishment__siret_link"
>
<Value
value={formatSiret(etablissement?.siret)}
/>
</Link>
</td>
<td>
<BadgeWithIcon
isTableBadge
text={stateText}
state={stateClass}
/>
</td>

<td>
<Value
value={joinNoFalsy(
[
etablissement?.codepostaletablissement,
etablissement?.libellecommuneetablissement,
],
" - "
)}
/>
</td>
<td>
<Value
value={
etablissement?.trancheeffectifsetablissement !==
"-" &&
etablissement?.trancheeffectifsetablissement !==
"NN" &&
etablissement?.trancheeffectifsetablissement !==
"SP"
? isActiveEstablishment(
etablissement?.etatadministratifetablissement
)
? staffSizeRanges[
etablissement
?.trancheeffectifsetablissement
]
: "0 salarié"
: staffSizeRanges[
etablissement
?.trancheeffectifsetablissement
]
}
/>
</td>
<td>
<Value value={etablissement?.etb_raisonsociale} />
</td>
<td>{`${
etablissement?.activiteprincipaleetablissement || ""
} - ${
getLibelletFromCodeNaf(
etablissement?.activiteprincipaleetablissement
) || ""
}`}</td>
</tr>
);
})}
</tbody>
<tbody>{renderTableBody()}</tbody>
</NonBorderedTable>
{etablissementsCount > 4 && (
{etablissementsCount > rowsPerPage && (
<div className="table-pagination">
<PaginationTable
currentPage={currentPage}
Expand Down
Loading

0 comments on commit 982341c

Please sign in to comment.