From 65f2a848b37e847a3b008d3846f13e1021a17bc7 Mon Sep 17 00:00:00 2001 From: Jalil Arfaoui Date: Mon, 30 Jan 2023 01:26:39 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20ajoute=20un=20filtre=20d=C3=A9partement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/ListeResistants.tsx | 38 ++++++++++++++++++++++++++++++++-- src/routes/ResistantRow.tsx | 2 +- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/routes/ListeResistants.tsx b/src/routes/ListeResistants.tsx index 2fcb09e..27e0812 100644 --- a/src/routes/ListeResistants.tsx +++ b/src/routes/ListeResistants.tsx @@ -1,3 +1,4 @@ +import React from "react"; import { Outlet, useLoaderData } from "react-router"; import {ResistantRow} from "./ResistantRow"; import {Resistant} from "../Resistant"; @@ -10,14 +11,47 @@ export const resistantsLoader = async () => { return { resistants } } +function FiltreDepartement(props: { onChange: (event: React.ChangeEvent) => void }) { + return ; +} + export const ListeResistants = () => { const { resistants } = useLoaderData() as { resistants: Resistant[] } + const [departement, setDepartement] = React.useState(null) + + const filtreDepartements = (event: React.ChangeEvent) => setDepartement(event.target.value) return ( <>
- {resistants.map((r) => )} - + + + {resistants + .filter(r => !departement || r.departement?.includes(departement)) + .map((r) => )} +
); diff --git a/src/routes/ResistantRow.tsx b/src/routes/ResistantRow.tsx index 19270ab..ac56960 100644 --- a/src/routes/ResistantRow.tsx +++ b/src/routes/ResistantRow.tsx @@ -13,7 +13,7 @@ export const ResistantRow = ({resistant}: Props) => {
-
+