Skip to content

Commit 1a4d253

Browse files
Add progress bar to the UI and shos amount_after_slash
1 parent f625255 commit 1a4d253

File tree

4 files changed

+82
-5
lines changed

4 files changed

+82
-5
lines changed

packages/app/components/MobileButtonRowLayout.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const ActivityRewards = ({ children, ...props }: XStackProps) => {
152152
const { data: distributions, isLoading } = useMonthlyDistributions()
153153
const distribution =
154154
distributions?.find((d) => d.number === queryParams.distribution) ?? distributions?.[0]
155-
const shareAmount = distribution?.distribution_shares?.[0]?.amount
155+
const shareAmount = distribution?.distribution_shares?.[0]?.amount_after_slash
156156

157157
const isVisible = distribution !== undefined && shareAmount !== undefined && shareAmount > 0
158158
const distributionMonth = distribution?.timezone_adjusted_qualification_end.toLocaleString(

packages/app/features/account/rewards/activity/screen.tsx

+75-1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ export function ActivityRewardsScreen() {
226226
<DistributionRequirementsCard distribution={distributions[selectedDistributionIndex]} />
227227
<SendPerksCards distribution={distributions[selectedDistributionIndex]} />
228228
<MultiplierCards distribution={distributions[selectedDistributionIndex]} />
229+
<RewardsProgressCard distribution={distributions[selectedDistributionIndex]} />
229230
<ClaimableRewardsCard distribution={distributions[selectedDistributionIndex]} />
230231
</YStack>
231232
)}
@@ -588,10 +589,83 @@ const MultiplierCard = ({ children }: PropsWithChildren<CardProps>) => {
588589
)
589590
}
590591

592+
const RewardsProgressCard = ({
593+
distribution,
594+
}: {
595+
distribution: UseDistributionsResultData[number]
596+
}) => {
597+
const shareAmount = distribution.distribution_shares?.[0]?.amount
598+
const slashedAmount = distribution.distribution_shares?.[0]?.amount_after_slash
599+
600+
if (!shareAmount || !slashedAmount) return null
601+
602+
const percentage = Math.floor((Number(slashedAmount) / Number(shareAmount)) * 100)
603+
604+
return (
605+
<YStack f={1} w={'100%'} gap="$5">
606+
<H3 fontWeight={'600'} color={'$color12'}>
607+
Progress
608+
</H3>
609+
<Card br={'$6'} p="$7" w={'100%'}>
610+
<YStack gap="$4" w="100%">
611+
<XStack jc="space-between" ai="center">
612+
<Paragraph color="$color11">Current Rewards</Paragraph>
613+
<Paragraph
614+
ff={'$mono'}
615+
py={'$size.0.5'}
616+
px={'$size.0.9'}
617+
borderWidth={1}
618+
borderColor={'$primary'}
619+
$theme-light={{ borderColor: '$color12' }}
620+
borderRadius={'$4'}
621+
>
622+
{percentage}%
623+
</Paragraph>
624+
</XStack>
625+
626+
<Stack w="100%" h="$1" br="$10" bc="$color3" overflow="hidden">
627+
<Stack
628+
w={`${percentage}%`}
629+
h="100%"
630+
br="$10"
631+
animation="quick"
632+
$theme-light={{
633+
bc: '$color12',
634+
}}
635+
$theme-dark={{
636+
bc: '$primary',
637+
}}
638+
/>
639+
</Stack>
640+
641+
<XStack jc="space-between" ai="center">
642+
<YStack>
643+
<Paragraph color="$color10" size="$3">
644+
Current
645+
</Paragraph>
646+
<Paragraph fontFamily="$mono" color="$color12">
647+
{formatAmount(slashedAmount, 9, 0)} SEND
648+
</Paragraph>
649+
</YStack>
650+
<YStack ai="flex-end">
651+
<Paragraph color="$color10" size="$3">
652+
Estimated Maximum
653+
</Paragraph>
654+
<Paragraph fontFamily="$mono" color="$color12">
655+
{formatAmount(shareAmount, 9, 0)} SEND
656+
</Paragraph>
657+
</YStack>
658+
</XStack>
659+
</YStack>
660+
</Card>
661+
</YStack>
662+
)
663+
}
664+
591665
const ClaimableRewardsCard = ({
592666
distribution,
593667
}: { distribution: UseDistributionsResultData[number] }) => {
594-
const shareAmount = distribution.distribution_shares?.[0]?.amount
668+
const shareAmount = distribution.distribution_shares?.[0]?.amount_after_slash
595669
if (shareAmount === undefined || shareAmount === 0) return null
596670
const now = new Date()
597671
const isQualificationOver = distribution.qualification_end < now

packages/app/features/account/rewards/components/DistributionClaimButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const DistributionClaimButton = ({ distribution }: DistributionsClaimButt
2828
const queryClient = useQueryClient()
2929
// Check if the user is eligible
3030
const share = distribution.distribution_shares?.[0]
31-
const isEligible = !!share && share.amount > 0
31+
const isEligible = !!share && share.amount_after_slash > 0
3232
const isClaimActive = distribution.qualification_end < new Date()
3333
const trancheId = BigInt(distribution.number - 1) // tranches are 0-indexed
3434
const chainId = distribution.chain_id as keyof typeof sendMerkleDropAddress

packages/app/features/account/rewards/screen.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,13 @@ export function RewardsScreen() {
5151
title="Activity Rewards"
5252
href="/account/rewards/activity"
5353
isLoading={isLoadingDistributions || isTrancheActiveLoading || isClaimedLoading}
54-
reward={currentDistribution?.distribution_shares?.[0]?.amount.toLocaleString() ?? ''}
54+
reward={
55+
currentDistribution?.distribution_shares?.[0]?.amount_after_slash.toLocaleString() ??
56+
''
57+
}
5558
claimStatus={(() => {
5659
switch (true) {
57-
case !share || !share.amount:
60+
case !share || !share.amount_after_slash:
5861
return undefined
5962
case !isTrancheActive:
6063
return 'Upcoming Reward'

0 commit comments

Comments
 (0)