Skip to content

Commit

Permalink
[IMP] Optimisation recup status current month
Browse files Browse the repository at this point in the history
  • Loading branch information
Landris18 committed Jun 10, 2024
1 parent b1965e4 commit 71fbe79
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/pages/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);


/**
Expand Down Expand Up @@ -655,7 +655,9 @@ export default function Dashboard() {
<Stack width={"100%"} height={"100%"} justifyContent={"space-between"} mt={3.5} pb={3}>
<Stack px={5}>
<Stack direction={"row"} bgcolor={`${colors.teal}09`} py={1} px={1.5} borderRadius={3} justifyContent={"space-between"} alignItems={"center"}>
<Avatar className='cursor-pointer' onClick={handleOpenProfileMenu} src={user?.avatar} sizes='md' alt={user?.username} sx={{ border: `4px solid ${hasPaidCurrentMonth ? "white" : colors.red}` }} />
<Avatar className='cursor-pointer' onClick={handleOpenProfileMenu} src={user?.avatar} sizes='md' alt={user?.username}
sx={{ border: `${hasPaidCurrentMonth ? "0px" : '4px'} solid ${hasPaidCurrentMonth ? "white" : colors.red}` }}
/>
<Stack width={"100%"} direction={"row"} justifyContent={"end"} alignItems={"center"} gap={1}>
{
isFullscreen ? (
Expand Down

0 comments on commit 71fbe79

Please sign in to comment.