Skip to content

Commit

Permalink
Allow user to increase fee without withdrawal
Browse files Browse the repository at this point in the history
  • Loading branch information
WRadoslaw committed Mar 20, 2024
1 parent f9e6643 commit 1b15594
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,10 @@ export const NftPurchaseBottomDrawer: FC = () => {

useEffect(() => {
if (!isOpen) {
setValue('bid', NaN)
setValue('bid', userBid?.amount ? hapiBnToTokenNumber(userBid.amount) : NaN)
}
}, [isOpen, setValue])
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isOpen, setValue, userBid?.amount.toString()])

const { isLoadingAsset: userBidAvatarLoading, urls: userBidAvatarUrls } = getMemberAvatar(userBid?.bidder)
const { isLoadingAsset: topBidderAvatarLoading, urls: topBidderAvatarUrls } = getMemberAvatar(topBidder)
Expand Down Expand Up @@ -476,7 +477,10 @@ export const NftPurchaseBottomDrawer: FC = () => {
value >= minimumBid ? true : 'Your bid must be higher than the minimum bid',
bidTooHigh: (value) => {
return accountBalance == null ||
value + hapiBnToTokenNumber(transactionFee) > hapiBnToTokenNumber(accountBalance)
value -
hapiBnToTokenNumber(new BN(userBid?.amount ?? 0)) +
hapiBnToTokenNumber(transactionFee) >
hapiBnToTokenNumber(accountBalance)
? 'You do not have enough funds to place this bid'
: true
},
Expand Down Expand Up @@ -566,12 +570,16 @@ export const NftPurchaseBottomDrawer: FC = () => {
</Text>
<Row>
<Text as="span" variant="t100" color={hasInsufficientFunds ? 'colorTextError' : 'colorText'}>
Your balance
{type !== 'buy_now' && !isBuyNowClicked && userBid?.amount ? 'Available bid balance' : 'Your balance'}
</Text>
{accountBalance != null ? (
<NumberFormat
as="span"
value={accountBalance}
value={
type !== 'buy_now' && !isBuyNowClicked
? accountBalance.add(new BN(userBid?.amount ?? 0))
: accountBalance
}
withToken
variant="t100"
color={hasInsufficientFunds ? 'colorTextError' : 'colorText'}
Expand Down

0 comments on commit 1b15594

Please sign in to comment.