From 71fbe79dc503f10de1ee63d043389970182d6928 Mon Sep 17 00:00:00 2001 From: Landris18 Date: Mon, 10 Jun 2024 18:11:30 +0300 Subject: [PATCH] [IMP] Optimisation recup status current month --- src/pages/Dashboard/Dashboard.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/pages/Dashboard/Dashboard.tsx b/src/pages/Dashboard/Dashboard.tsx index 7939ef3..1675589 100644 --- a/src/pages/Dashboard/Dashboard.tsx +++ b/src/pages/Dashboard/Dashboard.tsx @@ -229,16 +229,16 @@ export default function Dashboard() { }, [queryResults, user]); useEffect(() => { - const getStatusCotisationUser = (username: string) => { - if (cotisations && cotisations?.length > 0 && moisFilterGlobal === MONTHS[new Date().getMonth()] && anneeFilterGlobal === new Date().getFullYear()) { - const cotisation = cotisations.find((c: any) => c.username === username); - if (cotisation && cotisation?.montant) { + const getCurrentMonthStatus = (userId: number) => { + if (cotisationsMembres.length > 0) { + const filterByMembre: any = cotisationsMembres?.filter((ct: any) => ct.membre_id === userId)[0]; + if (filterByMembre["annees"][(new Date().getFullYear()).toString()].includes(MONTHS[new Date().getMonth()])) { setHasPaidCurrentMonth(true); } } } - getStatusCotisationUser(user?.username); - }, [anneeFilterGlobal, moisFilterGlobal, cotisations, user]); + getCurrentMonthStatus(user?.id); + }, [cotisationsMembres, user]); /** @@ -655,7 +655,9 @@ export default function Dashboard() { - + { isFullscreen ? (