Skip to content

Commit

Permalink
style: CR adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
aziolek committed Oct 4, 2024
1 parent 6be5ddf commit 54f6195
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
$elementMargin: 1.6rem;

.list {
display: flex;
flex-wrap: wrap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ const ProjectsSearchResults: FC<ProjectsSearchResultsProps> = ({
}
/>
))}
{isLoading &&
{projectsIpfsWithRewardsAndEpochs.length === 0 &&
isLoading &&
[...Array(5).keys()].map((_, index) => (
// eslint-disable-next-line react/no-array-index-key
<ProjectsListSkeletonItem key={index} className={styles.element} />
Expand Down
12 changes: 6 additions & 6 deletions client/src/hooks/queries/useSearchedProjectsDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export default function useSearchedProjectsDetails(

return {
data: queries.map(({ data }) => {
const rewards = data && data[1] ? data[1].rewards : [];
const address = data && data[4] ? data[4] : undefined;
const rewards = data?.[1]?.rewards ?? [];
const address = data?.[4];
const rewardsOfProject = rewards.find(element => element.address === address);
const rewardsOfProjectMatched = rewardsOfProject
? parseUnitsBigInt(rewardsOfProject.matched, 'wei')
Expand All @@ -80,13 +80,13 @@ export default function useSearchedProjectsDetails(
: BigInt(0);

return {
address: data && data[4] ? data[4] : undefined,
address,
donations: rewardsOfProjectAllocated,
epoch: data && data[3] ? data[3] : undefined,
epoch: data?.[3],
matchedRewards: rewardsOfProjectMatched,
numberOfDonors: data && data[2] ? data[2].length : 0,
numberOfDonors: data?.[2].length ?? 0,
totalValueOfAllocations: rewardsOfProjectMatched + rewardsOfProjectAllocated,
...(data && data[0] ? data[0] : {}),
...(data?.[0] ?? {}),
};
}),
isFetching: false,
Expand Down
23 changes: 21 additions & 2 deletions client/src/views/ProjectsView/ProjectsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const ProjectsView = (): ReactElement => {
const { data: currentEpoch } = useCurrentEpoch();

const [searchQuery, setSearchQuery] = useState<string>('');
// Helper hook, because actual fetch is called after debounce. Until then, loading state.
const [isProjectsSearchInProgress, setIsProjectsSearchInProgress] = useState<boolean>(false);
const [projectsSearchParameters, setProjectsSearchParameters] = useState<
ProjectsSearchParameters | undefined
>(undefined);
Expand Down Expand Up @@ -79,6 +81,13 @@ const ProjectsView = (): ReactElement => {
isFetching: isFetchingSearchedProjectsDetails,
} = useSearchedProjectsDetails(searchedProjects);

useEffect(() => {
if (isFetchingSearchedProjects || isFetchingSearchedProjectsDetails) {
return;
}
setIsProjectsSearchInProgress(false);
}, [isFetchingSearchedProjects, isFetchingSearchedProjectsDetails]);

useEffect(() => {
// Refetch is not required when no data already fetched.
if (statusSearchedProjects !== 'success') {
Expand Down Expand Up @@ -137,6 +146,10 @@ const ProjectsView = (): ReactElement => {
const query = e.target.value;
setSearchQuery(query);
setProjectsDetailsSearchParametersWrapperDebounced(query);

if (query !== '') {
setIsProjectsSearchInProgress(true);
}
};

const lastArchivedEpochNumber = useMemo(() => {
Expand Down Expand Up @@ -188,7 +201,13 @@ const ProjectsView = (): ReactElement => {
return (
<>
<ViewTitle className={styles.viewTitle}>
{t('viewTitle', { epochNumber: currentEpoch })}
{t('viewTitle', {
epochNumber:
isDecisionWindowOpen ||
(!isDecisionWindowOpen && areCurrentEpochsProjectsHiddenOutsideAllocationWindow)
? currentEpoch! - 1
: currentEpoch,
})}
</ViewTitle>
<div className={styles.searchAndFilter}>
<InputText
Expand Down Expand Up @@ -225,7 +244,7 @@ const ProjectsView = (): ReactElement => {
)}
{searchQuery !== '' && (
<ProjectsSearchResults
isLoading={isFetchingSearchedProjects || isFetchingSearchedProjectsDetails}
isLoading={isProjectsSearchInProgress}
orderOption={orderOption}
projectsIpfsWithRewardsAndEpochs={searchedProjectsDetails}
/>
Expand Down

0 comments on commit 54f6195

Please sign in to comment.