Skip to content

Commit

Permalink
fix: disable redeem flow when redemptions unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyd-eth committed Jul 19, 2024
1 parent 8f657a0 commit 70ef734
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
V2V3_CURRENCY_USD,
} from 'packages/v2v3/utils/currency'
import { formatCurrencyAmount } from 'packages/v2v3/utils/formatCurrencyAmount'
import { isInfiniteDistributionLimit } from 'packages/v2v3/utils/fundingCycle'
import { computeIssuanceRate } from 'packages/v2v3/utils/math'
import { ReactNode, useCallback, useEffect, useMemo, useState } from 'react'
import { twMerge } from 'tailwind-merge'
Expand Down Expand Up @@ -132,6 +133,9 @@ export const PayRedeemCard: React.FC<PayRedeemCardProps> = ({ className }) => {
return t`Project isn't currently issuing tokens`
}, [payerIssuanceRate, hasNfts, hasNftsLoading])

const redeemDisabled = project.fundingCycleMetadata?.redemptionRate.eq(0) ||
isInfiniteDistributionLimit(project.distributionLimit)

return (
<div className={twMerge('flex flex-col', className)}>
<div
Expand All @@ -146,16 +150,18 @@ export const PayRedeemCard: React.FC<PayRedeemCardProps> = ({ className }) => {
>
<Trans>Pay</Trans>
</ChoiceButton>
<ChoiceButton
selected={state === 'redeem'}
tooltip={t`Redeem tokens for a portion of this project's treasury`}
onClick={() => {
dispatch(payRedeemActions.changeToRedeem())
}}
disabled={!redeems.enabled}
>
<Trans>Redeem</Trans>
</ChoiceButton>
{redeemDisabled ? null : (
<ChoiceButton
selected={state === 'redeem'}
tooltip={t`Redeem tokens for a portion of this project's treasury`}
onClick={() => {
dispatch(payRedeemActions.changeToRedeem())
}}
disabled={!redeems.enabled}
>
<Trans>Redeem</Trans>
</ChoiceButton>
)}
</div>

<div className="mt-5">
Expand Down

0 comments on commit 70ef734

Please sign in to comment.