Skip to content

Commit

Permalink
Merge pull request #385 from merofinance/empty-state-for-pools
Browse files Browse the repository at this point in the history
Add Empty State for Pools
  • Loading branch information
chase-manning authored Feb 26, 2024
2 parents b7126c7 + 756a693 commit fa48317
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
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

0 comments on commit fa48317

Please sign in to comment.