From cd156b5521275a722f6f4424bce07940813ce17b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Zi=C3=B3=C5=82ek?= Date: Wed, 10 Apr 2024 00:10:55 +0200 Subject: [PATCH] fix: fetching of donors of projects --- .../Project/ProjectDonorsHeader/ProjectDonorsHeader.tsx | 6 +++++- .../Project/ProjectDonorsList/ProjectDonorsList.tsx | 7 ++++++- client/src/views/ProjectView/ProjectView.tsx | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/client/src/components/Project/ProjectDonorsHeader/ProjectDonorsHeader.tsx b/client/src/components/Project/ProjectDonorsHeader/ProjectDonorsHeader.tsx index 467df31a3d..47b84ad019 100644 --- a/client/src/components/Project/ProjectDonorsHeader/ProjectDonorsHeader.tsx +++ b/client/src/components/Project/ProjectDonorsHeader/ProjectDonorsHeader.tsx @@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next'; import { useParams } from 'react-router-dom'; import useProjectDonors from 'hooks/queries/donors/useProjectDonors'; +import useCurrentEpoch from 'hooks/queries/useCurrentEpoch'; import styles from './ProjectDonorsHeader.module.scss'; import ProjectDonorsListProps from './types'; @@ -15,10 +16,13 @@ const ProjectDonorsHeader: FC = ({ }) => { const { epoch } = useParams(); const { i18n } = useTranslation('translation'); + const { data: currentEpoch } = useCurrentEpoch(); + + const epochNumber = parseInt(epoch!, 10); const { data: projectDonors, isFetching } = useProjectDonors( projectAddress, - parseInt(epoch!, 10), + epochNumber === currentEpoch ? undefined : epochNumber, ); return (
diff --git a/client/src/components/Project/ProjectDonorsList/ProjectDonorsList.tsx b/client/src/components/Project/ProjectDonorsList/ProjectDonorsList.tsx index 6ce1161248..f68f04ad39 100644 --- a/client/src/components/Project/ProjectDonorsList/ProjectDonorsList.tsx +++ b/client/src/components/Project/ProjectDonorsList/ProjectDonorsList.tsx @@ -7,6 +7,7 @@ import ProjectDonorsListSkeletonItem from 'components/Project/ProjectDonorsListS import ProjectDonorsListTotalDonated from 'components/Project/ProjectDonorsListTotalDonated'; import { DONORS_SHORT_LIST_LENGTH } from 'constants/donors'; import useProjectDonors from 'hooks/queries/donors/useProjectDonors'; +import useCurrentEpoch from 'hooks/queries/useCurrentEpoch'; import styles from './ProjectDonorsList.module.scss'; import ProjectDonorsListProps from './types'; @@ -18,9 +19,13 @@ const ProjectDonorsList: FC = ({ showFullList = false, }) => { const { epoch } = useParams(); + const { data: currentEpoch } = useCurrentEpoch(); + + const epochNumber = parseInt(epoch!, 10); + const { data: projectDonors, isFetching } = useProjectDonors( projectAddress, - parseInt(epoch!, 10), + epochNumber === currentEpoch ? undefined : epochNumber, ); return ( diff --git a/client/src/views/ProjectView/ProjectView.tsx b/client/src/views/ProjectView/ProjectView.tsx index d0126f2c79..568ef24ac9 100644 --- a/client/src/views/ProjectView/ProjectView.tsx +++ b/client/src/views/ProjectView/ProjectView.tsx @@ -32,7 +32,7 @@ const ProjectView = (): ReactElement => { const { data: currentEpoch } = useCurrentEpoch(); const epochUrlInt = parseInt(epochUrl!, 10); - const epoch = isDecisionWindowOpen && epochUrlInt === currentEpoch! - 1 ? undefined : epochUrlInt; + const epoch = epochUrlInt === currentEpoch ? undefined : epochUrlInt; const { data: matchedProjectRewards } = useMatchedProjectRewards(epoch); const { data: projectsIpfsWithRewards } = useProjectsIpfsWithRewards(epoch);