1- import { ModalStep , useModal } from '@getpara/react-sdk-lite'
21import { ArrowDownIcon , MinusIcon , PlusIcon } from '@heroicons/react/24/outline'
2+ import { ModalStep , useModal } from '@getpara/react-sdk-lite'
33import React , { ReactNode , useCallback , useMemo } from 'react'
44
5- import { t } from '@lingui/macro'
6- import { Tooltip } from 'antd'
5+ import { CURRENCY_METADATA } from 'constants/currency'
76import CurrencySymbol from 'components/currency/CurrencySymbol'
7+ import { EthereumLogo } from './EthereumLogo'
8+ import { NftRewardTier } from 'models/nftRewards'
9+ import { ProjectCartNftReward } from '../ReduxProjectCartProvider'
810import { SmallNftSquare } from 'components/NftRewards/SmallNftSquare'
11+ import { Tooltip } from 'antd'
912import { TruncatedText } from 'components/TruncatedText'
10- import { CURRENCY_METADATA } from 'constants/currency'
11- import { emitConfirmationDeletionModal } from 'hooks/emitConfirmationDeletionModal'
12- import { useCurrencyConverter } from 'hooks/useCurrencyConverter'
13- import { useWallet } from 'hooks/Wallet'
14- import { NftRewardTier } from 'models/nftRewards'
15- import { useV4NftRewards } from 'packages/v4/contexts/V4NftRewards/V4NftRewardsProvider'
16- import { useV4UserNftCredits } from 'packages/v4/contexts/V4UserNftCreditsProvider'
17- import { useNftCartItem } from 'packages/v4/hooks/useNftCartItem'
1813import { V4_CURRENCY_USD } from 'packages/v4/utils/currency'
14+ import { emitConfirmationDeletionModal } from 'hooks/emitConfirmationDeletionModal'
15+ import { formatAmount } from 'utils/format/formatAmount'
1916import { formatCurrencyAmount } from 'packages/v4/utils/formatCurrencyAmount'
20- import { useProjectPageQueries } from 'packages/v4/views/V4ProjectDashboard/hooks/useProjectPageQueries '
17+ import { t } from '@lingui/macro '
2118import { twMerge } from 'tailwind-merge'
22- import { formatAmount } from 'utils/format/formatAmount'
23- import { ProjectCartNftReward } from '../ReduxProjectCartProvider'
24- import { EthereumLogo } from './EthereumLogo'
19+ import { useCurrencyConverter } from 'hooks/useCurrencyConverter'
20+ import { useNftCartItem } from 'packages/v4/hooks/useNftCartItem'
2521import { usePayAmounts } from './PayProjectModal/hooks/usePayAmounts'
22+ import { useProjectPageQueries } from 'packages/v4/views/V4ProjectDashboard/hooks/useProjectPageQueries'
23+ import { useV4NftRewards } from 'packages/v4/contexts/V4NftRewards/V4NftRewardsProvider'
24+ import { useV4UserNftCredits } from 'packages/v4/contexts/V4UserNftCreditsProvider'
25+ import { useWallet } from 'hooks/Wallet'
2626
2727const MAX_AMOUNT = BigInt ( Number . MAX_SAFE_INTEGER )
2828
@@ -113,8 +113,9 @@ export const PayRedeemInput = ({
113113 return null
114114 }
115115
116+
116117 const showGetEth =
117- actionType === 'pay' && token . balance === '0' && userAddress
118+ actionType === 'pay'
118119 return (
119120 < div className = "relative" >
120121 < div
@@ -173,7 +174,7 @@ export const PayRedeemInput = ({
173174 < div className = "my-2 h-[1px] w-full border-t border-grey-200 dark:border-slate-600" />
174175 ) }
175176
176- { nfts && nfts ?. length > 0 && readOnly && actionType === 'pay ' && (
177+ { nfts && nfts ?. length > 0 && readOnly && actionType === 'redeem ' && (
177178 < div className = "mt-4 space-y-4" >
178179 { nfts . map ( ( nft , i ) => {
179180 const quantity =
@@ -293,7 +294,8 @@ export const PayRedeemCardNftReward: React.FC<{
293294 decreaseQuantity ( )
294295 }
295296 } , [ decreaseQuantity , handleRemove , quantity ] )
296-
297+
298+ const remaining = nft . remainingSupply
297299 return (
298300 < div
299301 className = { twMerge ( 'flex items-center justify-between gap-3' , className ) }
@@ -326,11 +328,14 @@ export const PayRedeemCardNftReward: React.FC<{
326328 </ div >
327329
328330 < div className = "flex items-center gap-3" >
329- < QuantityControl
330- quantity = { quantity }
331- onIncrease = { handleIncreaseQuantity }
332- onDecrease = { handleDecreaseQuantity }
333- />
331+ < Tooltip title = { remaining === 0 ? t `NFT is sold out` : undefined } >
332+ < QuantityControl
333+ quantity = { quantity }
334+ onIncrease = { handleIncreaseQuantity }
335+ onDecrease = { handleDecreaseQuantity }
336+ disabled = { remaining === 0 }
337+ />
338+ </ Tooltip >
334339 </ div >
335340 </ div >
336341 )
@@ -340,14 +345,24 @@ const QuantityControl: React.FC<{
340345 quantity : number
341346 onIncrease : ( ) => void
342347 onDecrease : ( ) => void
343- } > = ( { quantity, onIncrease, onDecrease } ) => {
348+ disabled ?: boolean
349+ } > = ( { quantity, onIncrease, onDecrease, disabled } ) => {
344350 return (
345351 < span className = "flex w-fit gap-3 rounded-lg border border-grey-200 p-1 text-sm dark:border-slate-600" >
346- < button data-testid = "cart-item-decrease-button" onClick = { onDecrease } >
352+ < button
353+ data-testid = "cart-item-decrease-button"
354+ onClick = { quantity === 0 ? undefined : onDecrease }
355+ className = { quantity === 0 ? "opacity-50 cursor-not-allowed" : "" }
356+ >
347357 < MinusIcon className = "h-4 w-4 text-grey-500 dark:text-slate-200" />
348358 </ button >
349359 { quantity }
350- < button data-testid = "cart-item-increase-button" onClick = { onIncrease } >
360+ < button
361+ data-testid = "cart-item-increase-button"
362+ onClick = { onIncrease }
363+ disabled = { disabled }
364+ className = { disabled ? "opacity-50 cursor-not-allowed" : "" }
365+ >
351366 < PlusIcon className = "h-4 w-4 text-grey-500 dark:text-slate-200" />
352367 </ button >
353368 </ span >
0 commit comments