Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Empty State for Pools #385

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
"header": "All pools",
"overview": "Mero’s single-asset pools aggregate yield across strategies. Add utility and autonomy to your liquidity with actions.",
"deposit": "deposit",
"emptyState": "All Mero pools are currently paused",
"information": {
"header": "Pools information",
"tvl": {
Expand Down
49 changes: 32 additions & 17 deletions src/pages/pools/PoolsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ const InfoCards = styled.div`
}
`;

const EmptyState = styled.div`
width: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 1.6rem;
font-weight: 500;
padding: 3rem 0 2rem 0;
`;

const PoolsPage = (): JSX.Element => {
const { t } = useTranslation();
const navigate = useNavigate();
Expand All @@ -107,6 +117,21 @@ const PoolsPage = (): JSX.Element => {
dispatch(fetchState(mero));
}, [updated]);

const activePools = pools
? pools
.filter((pool: Pool) => {
const paused = pool.isPaused || pool.isShutdown;
if (!paused) return true;
if (!balances || !balances[pool.address]) return false;
return !balances[pool.address].isZero();
})
.sort((a: Pool, b: Pool) => (a.apy && b.apy ? b.apy.toNumber() - a.apy.toNumber() : 0))
.sort((a: Pool, b: Pool) => {
if (!balances || !balances[a.address] || !balances[b.address]) return 0;
return balances[b.address].toNumber() - balances[a.address].toNumber();
})
: null;

return (
<StyledPoolsPage>
<Seo title={t("metadata.pools.title")} description={t("metadata.pools.description")} />
Expand All @@ -131,29 +156,19 @@ const PoolsPage = (): JSX.Element => {
<Header hideOnMobile>{t("headers.deposits")}</Header>
<ChevronHeader />
</HeaderRow>
{!pools && (
{!activePools && (
<>
<Loader row />
<Loader row />
<Loader row />
</>
)}
{pools &&
pools
.filter((pool: Pool) => {
const paused = pool.isPaused || pool.isShutdown;
if (!paused) return true;
if (!balances || !balances[pool.address]) return false;
return !balances[pool.address].isZero();
})
.sort((a: Pool, b: Pool) =>
a.apy && b.apy ? b.apy.toNumber() - a.apy.toNumber() : 0
)
.sort((a: Pool, b: Pool) => {
if (!balances || !balances[a.address] || !balances[b.address]) return 0;
return balances[b.address].toNumber() - balances[a.address].toNumber();
})
.map((pool: Pool) => <PoolsRow key={pool.address} pool={pool} />)}
{activePools && activePools.length === 0 && (
<EmptyState>{t("pools.emptyState")}</EmptyState>
)}
{activePools &&
activePools.length > 0 &&
activePools.map((pool: Pool) => <PoolsRow key={pool.address} pool={pool} />)}
</ContentSection>
</ContentContainer>
<InfoCards>
Expand Down
Loading