feat: affiche les anciens résistants en dernier

proto-module-actu-react
Jalil Arfaoui 2023-08-31 18:49:20 +02:00
parent be6194ad1f
commit 365ddaf7d4
2 changed files with 10 additions and 1 deletions

View File

@ -18,3 +18,6 @@ export const isAncienResistant = (resistant: Resistant): boolean =>
Boolean( Boolean(
resistant.date_fin_resistance && resistant.date_fin_resistance !== "" resistant.date_fin_resistance && resistant.date_fin_resistance !== ""
); );
export const isResistantActif = (resistant: Resistant): boolean =>
!isAncienResistant(resistant);

View File

@ -17,6 +17,7 @@ import { ResistantsThumbs } from "./Thumbs/ResistantsThumbs";
import { FiltreDepartement } from "./FiltreDepartement"; import { FiltreDepartement } from "./FiltreDepartement";
import { ResistantRow } from "./List/ResistantRow"; import { ResistantRow } from "./List/ResistantRow";
import { HomeContext } from "../../context/HomeContext"; import { HomeContext } from "../../context/HomeContext";
import { isAncienResistant, isResistantActif } from "../../Resistant";
const normalize = (text: string) => const normalize = (text: string) =>
(text || "") (text || "")
@ -46,7 +47,12 @@ export const ListeResistants = () => {
) )
.filter( .filter(
(r) => !academie || normalize(r.academie).includes(normalize(academie)) (r) => !academie || normalize(r.academie).includes(normalize(academie))
); )
.sort((r1, r2) => {
if (isResistantActif(r1) && isAncienResistant(r2)) return -1;
if (isAncienResistant(r1) && isResistantActif(r2)) return 1;
return 0;
});
return ( return (
<> <>