Skip to content

Commit

Permalink
fix: ProjectDonorsHeader -- show 0 when epochNumber === currentEpoch
Browse files Browse the repository at this point in the history
  • Loading branch information
aziolek committed Apr 11, 2024
1 parent 5ec8d33 commit b43aefa
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cx from 'classnames';
import React, { FC } from 'react';
import React, { FC, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';

Expand All @@ -24,11 +24,19 @@ const ProjectDonorsHeader: FC<ProjectDonorsListProps> = ({
projectAddress,
epochNumber === currentEpoch ? undefined : epochNumber,
);

const numberOfDonors = useMemo(() => {
if (epochNumber === currentEpoch) {
return 0;
}
return isFetching ? '--' : projectDonors?.length;
}, [isFetching, projectDonors, epochNumber, currentEpoch]);

return (
<div className={cx(styles.header, className)} data-test={dataTest}>
<span className={styles.headerLabel}>{i18n.t('common.donors')}</span>{' '}
<div className={styles.count} data-test={`${dataTest}__count`}>
{isFetching ? '--' : projectDonors?.length}
{numberOfDonors}
</div>
</div>
);
Expand Down

0 comments on commit b43aefa

Please sign in to comment.