From 3aa61ad63fcd188776ad0c0a923a94c9f4a88f4b Mon Sep 17 00:00:00 2001 From: Arnaud AMBROSELLI Date: Thu, 1 Feb 2024 11:49:14 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20possibilit=C3=A9=20de=20chercher=20une?= =?UTF-8?q?=20structure=20par=20npom,=20cat=C3=A9gorie,=20ville,=20etc.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dashboard/src/scenes/structure/list.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/dashboard/src/scenes/structure/list.js b/dashboard/src/scenes/structure/list.js index b55039b16..a5f212da9 100644 --- a/dashboard/src/scenes/structure/list.js +++ b/dashboard/src/scenes/structure/list.js @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useMemo, useState } from 'react'; import { SmallHeader } from '../../components/header'; import Loading from '../../components/loading'; import Table from '../../components/table'; @@ -13,6 +13,7 @@ import SelectCustom from '../../components/SelectCustom'; import { useRecoilValue } from 'recoil'; import { userState } from '../../recoil/auth'; import { flattenedStructuresCategoriesSelector } from '../../recoil/structures'; +import { filterBySearch } from '../search/utils'; const List = () => { const [structures, setStructures] = useState([]); @@ -22,10 +23,14 @@ const List = () => { const [currentStructure, setCurrentStructure] = useState(null); const [currentStructureOpen, setCurrentStructureOpen] = useState(false); + const filteredStructures = useMemo(() => { + return filterBySearch(search, structures); + }, [search, structures]); + useTitle('Structures'); const getStructures = async () => { - const response = await API.get({ path: '/structure', query: { search } }); + const response = await API.get({ path: '/structure' }); if (response.ok) { setStructures(response.data); } @@ -34,14 +39,13 @@ const List = () => { useEffect(() => { getStructures(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [search]); + }, []); if (isLoading) return ; return ( <> - +
{ - +
{ setCurrentStructure(s); @@ -79,10 +83,10 @@ const List = () => { { title: 'Nom', dataKey: 'name', - render: (structures) => { + render: (structure) => { return (
- {structures.name} + {structure.name}
); }, @@ -91,8 +95,8 @@ const List = () => { { title: 'Adresse', dataKey: 'adresse', - render: (structures) => { - return
{structures.adresse}
; + render: (structure) => { + return
{structure.adresse}
; }, }, { title: 'Code postal', dataKey: 'postcode' },