-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from valory-xyz/mohan/staked-olas-status
feat: Show status of staked OLAS amount
- Loading branch information
Showing
13 changed files
with
100 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
export const balanceFormat = ( | ||
balance: number | undefined, | ||
decimals: 2, | ||
): string => | ||
balance === undefined | ||
? '--' | ||
: Intl.NumberFormat('en-US', { | ||
notation: 'compact', | ||
maximumFractionDigits: decimals, | ||
minimumFractionDigits: decimals, | ||
}).format(balance); | ||
): string => { | ||
if (balance === undefined) return '--'; | ||
return Intl.NumberFormat('en-US', { | ||
notation: 'compact', | ||
maximumFractionDigits: decimals, | ||
minimumFractionDigits: decimals, | ||
}).format(balance); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,77 @@ | ||
import { Flex, Skeleton, Tag, Typography } from 'antd'; | ||
import { memo } from 'react'; | ||
import { Col, Flex, Row, Skeleton, Tag, Typography } from 'antd'; | ||
import styled from 'styled-components'; | ||
|
||
import { balanceFormat } from '@/common-util'; | ||
import { COLOR } from '@/constants'; | ||
import { useBalance } from '@/hooks'; | ||
import { useReward } from '@/hooks/useReward'; | ||
|
||
import { CardSection } from '../styled/CardSection'; | ||
|
||
const { Text } = Typography; | ||
|
||
const Loader = styled.div` | ||
display: flex; | ||
align-items: center; | ||
gap: 14px; | ||
margin-top: 4px; | ||
const RewardsRow = styled(Row)` | ||
margin: 0 -24px; | ||
> .ant-col { | ||
padding: 24px; | ||
border-right: 1px solid ${COLOR.BORDER_GRAY}; | ||
} | ||
`; | ||
|
||
export const MainRewards = () => { | ||
const DisplayRewards = () => { | ||
const { availableRewardsForEpochEth, isEligibleForRewards } = useReward(); | ||
const { isBalanceLoaded } = useBalance(); | ||
const { isBalanceLoaded, totalOlasStakedBalance } = useBalance(); | ||
|
||
// 20 OLAS is the minimum amount to stake | ||
const isStaked = totalOlasStakedBalance === 20; | ||
|
||
return ( | ||
<CardSection gap={5} vertical> | ||
<Text>Staking rewards today </Text> | ||
{isBalanceLoaded ? ( | ||
<Flex gap={10}> | ||
<Text strong> | ||
{balanceFormat(availableRewardsForEpochEth, 2)} OLAS | ||
</Text> | ||
<RewardsEarned isEligibleForRewards={isEligibleForRewards} /> | ||
<RewardsRow> | ||
<Col span={12}> | ||
<Flex vertical gap={4} align="flex-start"> | ||
<Text>Staking rewards today</Text> | ||
{isBalanceLoaded ? ( | ||
<> | ||
<Text strong style={{ fontSize: 20 }}> | ||
{balanceFormat(availableRewardsForEpochEth, 2)} OLAS | ||
</Text> | ||
{isEligibleForRewards ? ( | ||
<Tag color="success">Earned</Tag> | ||
) : ( | ||
<Tag color="processing">Not yet earned</Tag> | ||
)} | ||
</> | ||
) : ( | ||
<Flex vertical gap={8}> | ||
<Skeleton.Button active size="small" style={{ width: 92 }} /> | ||
<Skeleton.Button active size="small" style={{ width: 92 }} /> | ||
</Flex> | ||
)} | ||
</Flex> | ||
</Col> | ||
|
||
<Col span={12}> | ||
<Flex vertical gap={4} align="flex-start"> | ||
<Text>Staked amount</Text> | ||
{isBalanceLoaded ? ( | ||
<> | ||
<Text strong style={{ fontSize: 20 }}> | ||
{balanceFormat(totalOlasStakedBalance, 2)} OLAS | ||
</Text> | ||
{isStaked ? null : <Tag color="processing">Not yet staked</Tag>} | ||
</> | ||
) : ( | ||
<Flex vertical gap={8}> | ||
<Skeleton.Button active size="small" style={{ width: 92 }} /> | ||
<Skeleton.Button active size="small" style={{ width: 92 }} /> | ||
</Flex> | ||
)} | ||
</Flex> | ||
) : ( | ||
<Loader> | ||
<Skeleton.Button active size="small" style={{ width: 92 }} /> | ||
<Skeleton.Button active size="small" style={{ width: 92 }} /> | ||
</Loader> | ||
)} | ||
</CardSection> | ||
</Col> | ||
</RewardsRow> | ||
); | ||
}; | ||
|
||
const RewardsEarned = memo(function RewardsEarned({ | ||
isEligibleForRewards, | ||
}: { | ||
isEligibleForRewards?: boolean; | ||
}) { | ||
if (!isEligibleForRewards) | ||
return <Tag color="processing">Not yet earned</Tag>; | ||
return <Tag color="success">Earned</Tag>; | ||
}); | ||
export const MainRewards = () => ( | ||
<> | ||
<DisplayRewards /> | ||
</> | ||
); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ html, body { | |
} | ||
|
||
body { | ||
max-width: 420px; | ||
max-width: 460px; | ||
border-radius: 8px; | ||
user-select: none; | ||
} | ||
|