-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OCT-1942 Projects search: client (#461)
- Loading branch information
Showing
35 changed files
with
685 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
client/src/components/Projects/ProjectsList/ProjectsList.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
client/src/components/Projects/ProjectsSearchResults/ProjectsSearchResults.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
$elementMargin: 1.6rem; | ||
|
||
.noSearchResults { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
flex: 1; | ||
color: $color-octant-grey5; | ||
margin: 1.6rem 0; | ||
|
||
.image { | ||
width: 28rem; | ||
margin-bottom: 3.2rem; | ||
} | ||
} | ||
|
||
.list { | ||
display: flex; | ||
flex-wrap: wrap; | ||
width: 100%; | ||
justify-content: space-between; | ||
} |
75 changes: 75 additions & 0 deletions
75
client/src/components/Projects/ProjectsSearchResults/ProjectsSearchResults.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React, { FC, memo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import ProjectsListItem from 'components/Projects/ProjectsListItem'; | ||
import ProjectsListSkeletonItem from 'components/Projects/ProjectsListSkeletonItem'; | ||
import Grid from 'components/shared/Grid'; | ||
import Img from 'components/ui/Img'; | ||
import useSortedProjects from 'hooks/helpers/useIdsInAllocation/useSortedProjects'; | ||
import useCurrentEpoch from 'hooks/queries/useCurrentEpoch'; | ||
import useIsDecisionWindowOpen from 'hooks/queries/useIsDecisionWindowOpen'; | ||
|
||
import styles from './ProjectsSearchResults.module.scss'; | ||
import ProjectsSearchResultsProps from './types'; | ||
|
||
const ProjectsSearchResults: FC<ProjectsSearchResultsProps> = ({ | ||
orderOption, | ||
projectsIpfsWithRewardsAndEpochs, | ||
isLoading, | ||
}) => { | ||
const { t } = useTranslation('translation', { | ||
keyPrefix: 'components.dedicated.projectsSearchResults', | ||
}); | ||
|
||
const { data: currentEpoch } = useCurrentEpoch(); | ||
const { data: isDecisionWindowOpen } = useIsDecisionWindowOpen(); | ||
|
||
const projectsIpfsWithRewardsSorted = useSortedProjects( | ||
projectsIpfsWithRewardsAndEpochs, | ||
orderOption, | ||
); | ||
|
||
return ( | ||
<div className={styles.list}> | ||
{projectsIpfsWithRewardsAndEpochs.length === 0 && !isLoading && ( | ||
<div className={styles.noSearchResults}> | ||
<Img | ||
className={styles.image} | ||
dataTest="ProjectsList__noSearchResults__Img" | ||
src="images/swept.webp" | ||
/> | ||
{t('noSearchResults')} | ||
</div> | ||
)} | ||
<Grid> | ||
{projectsIpfsWithRewardsAndEpochs.length > 0 && | ||
!isLoading && | ||
projectsIpfsWithRewardsSorted.map((projectIpfsWithRewards, index) => ( | ||
<ProjectsListItem | ||
key={`${projectIpfsWithRewards.address}--${projectIpfsWithRewards.epoch}`} | ||
dataTest={ | ||
projectIpfsWithRewards.epoch | ||
? `ProjectsView__ProjectsListItem--archive--${index}` | ||
: `ProjectsView__ProjectsListItem--${index}` | ||
} | ||
epoch={projectIpfsWithRewards.epoch} | ||
projectIpfsWithRewards={projectIpfsWithRewards} | ||
searchResultsLabel={ | ||
isDecisionWindowOpen && currentEpoch === projectIpfsWithRewards.epoch | ||
? '' | ||
: t('searchResultsLabel', { epochNumber: projectIpfsWithRewards.epoch }) | ||
} | ||
/> | ||
))} | ||
{projectsIpfsWithRewardsAndEpochs.length === 0 && | ||
isLoading && | ||
[...Array(5).keys()].map((_, index) => ( | ||
// eslint-disable-next-line react/no-array-index-key | ||
<ProjectsListSkeletonItem key={index} className={styles.element} /> | ||
))} | ||
</Grid> | ||
</div> | ||
); | ||
}; | ||
|
||
export default memo(ProjectsSearchResults); |
2 changes: 2 additions & 0 deletions
2
client/src/components/Projects/ProjectsSearchResults/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// eslint-disable-next-line no-restricted-exports | ||
export { default } from './ProjectsSearchResults'; |
8 changes: 8 additions & 0 deletions
8
client/src/components/Projects/ProjectsSearchResults/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ProjectsIpfsWithRewardsAndEpochs } from 'hooks/queries/useSearchedProjectsDetails'; | ||
import { OrderOption } from 'views/ProjectsView/types'; | ||
|
||
export default interface ProjectsSearchResultsProps { | ||
isLoading: boolean; | ||
orderOption: OrderOption; | ||
projectsIpfsWithRewardsAndEpochs: ProjectsIpfsWithRewardsAndEpochs[]; | ||
} |
Oops, something went wrong.