Skip to content

Commit ef8a3cd

Browse files
committed
fix: redpacket claimed with user's other wallet
1 parent 82fc8b4 commit ef8a3cd

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

packages/plugins/RedPacket/src/SiteAdaptor/RedPacket/RedPacketEnvelope.tsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Trans } from '@lingui/macro'
22
import { NetworkIcon, TokenIcon } from '@masknet/shared'
33
import { NetworkPluginID } from '@masknet/shared-base'
44
import { makeStyles } from '@masknet/theme'
5-
import { formatBalance, type FungibleToken } from '@masknet/web3-shared-base'
5+
import { formatBalance, isZero, type FungibleToken } from '@masknet/web3-shared-base'
66
import { type ChainId, type SchemaType } from '@masknet/web3-shared-evm'
77
import { Typography } from '@mui/material'
88
import type { HTMLProps } from 'react'
@@ -160,6 +160,7 @@ export function RedPacketEnvelope({
160160
...props
161161
}: Props) {
162162
const { classes, cx } = useStyles()
163+
const claimedZero = isZero(claimedAmount)
163164
return (
164165
<div {...props} className={cx(classes.container, props.className)}>
165166
<img src={cover} className={classes.cover} />
@@ -181,18 +182,25 @@ export function RedPacketEnvelope({
181182
chainId={token.chainId}
182183
/>
183184
</div>
184-
<Typography className={classes.amount}>
185-
{isClaimed ?
186-
formatBalance(claimedAmount, token.decimals)
187-
: `${formatBalance(totalClaimed, token.decimals)} / ${formatBalance(total, token.decimals)}`
188-
}{' '}
189-
{token.symbol}
190-
</Typography>
185+
{isClaimed ?
186+
<Typography className={classes.amount}>
187+
{claimedZero ?
188+
<Trans>You have already claimed this lucky drop.</Trans>
189+
: `${formatBalance(claimedAmount, token.decimals)} ${token.symbol}`}
190+
</Typography>
191+
: <Typography className={classes.amount}>
192+
{`${formatBalance(totalClaimed, token.decimals)} / ${formatBalance(total, token.decimals)} `}
193+
{token.symbol}
194+
</Typography>
195+
}
191196
<div className={classes.status}>
192197
{isClaimed ?
193-
<Typography className={classes.statusText}>
194-
<Trans>Congratulations!</Trans>
195-
</Typography>
198+
claimedZero ?
199+
null
200+
: <Typography className={classes.statusText}>
201+
<Trans>Congratulations!</Trans>
202+
</Typography>
203+
196204
: isEmpty ?
197205
<>
198206
<div className={classes.bar}>

0 commit comments

Comments
 (0)