Skip to content

Commit

Permalink
fix: fetching of donors of projects
Browse files Browse the repository at this point in the history
  • Loading branch information
aziolek committed Apr 9, 2024
1 parent febf622 commit cd156b5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -15,10 +16,13 @@ const ProjectDonorsHeader: FC<ProjectDonorsListProps> = ({
}) => {
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 (
<div className={cx(styles.header, className)} data-test={dataTest}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -18,9 +19,13 @@ const ProjectDonorsList: FC<ProjectDonorsListProps> = ({
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 (
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/ProjectView/ProjectView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cd156b5

Please sign in to comment.