Skip to content

Commit

Permalink
redeem button: make distinct from claim button
Browse files Browse the repository at this point in the history
  • Loading branch information
mantikoros committed Sep 24, 2024
1 parent 0819440 commit a9a2ff2
Showing 1 changed file with 13 additions and 35 deletions.
48 changes: 13 additions & 35 deletions web/components/profile/redeem-sweeps-buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,32 @@ import { useRouter } from 'next/router'
import { useAPIGetter } from 'web/hooks/use-api-getter'
import { Button } from '../buttons/button'
import { CoinNumber } from '../widgets/coin-number'
import { KYC_VERIFICATION_BONUS_CASH } from 'common/economy'
import { useKYCGiftAmount } from '../twomba/sweep-verify-section'
import { SweepiesCoin } from 'web/public/custom-components/sweepiesCoin'
import { blockFromSweepstakes } from 'common/gidx/user'

export function RedeemSweepsButtons(props: { user: User; className?: string }) {
const { user, className } = props
const { className } = props
const { data: redeemable } = useAPIGetter('get-redeemable-prize-cash', {})
const redeemableCash = redeemable?.redeemablePrizeCash ?? 0
const router = useRouter()

const canRedeem = user.sweepstakesVerified && !blockFromSweepstakes(user)

const kycGift = useKYCGiftAmount(user)

const onClick = () => {
router.push('/redeem')
}

return (
<>
{canRedeem ? (
<Button onClick={onClick} color={'amber'} className={className}>
Redeem
{redeemableCash > 0 ? (
<CoinNumber
amount={redeemableCash}
className="ml-1"
coinType="sweepies"
/>
) : (
<SweepiesCoin className="ml-1" />
)}
</Button>
) : (
<Button onClick={onClick} color={'amber'} className={className}>
Claim
{kycGift == undefined ? (
<CoinNumber
amount={KYC_VERIFICATION_BONUS_CASH}
coinType="CASH"
className="ml-1"
/>
) : (
<CoinNumber amount={kycGift} coinType="CASH" className="ml-1" />
)}
</Button>
)}
<Button onClick={onClick} color={'amber'} className={className}>
Redeem
{redeemableCash > 0 ? (
<CoinNumber
amount={redeemableCash}
className="ml-1"
coinType="sweepies"
/>
) : (
<SweepiesCoin className="ml-1" />
)}
</Button>
</>
)
}

0 comments on commit a9a2ff2

Please sign in to comment.