Skip to content

Commit

Permalink
Merge pull request #1496 from AmbireTech/fix/modal-close-claimable-modal
Browse files Browse the repository at this point in the history
Fix / Close Rewards And Unbound Modals On Claim
  • Loading branch information
stojnovsky authored Dec 14, 2023
2 parents 0bda566 + 52d4846 commit d53b73a
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/components/Modals/WalletTokenModal/WalletTokenModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { rpcProviders } from 'config/providers'
import { formatFloatTokenAmount } from 'lib/formatters'

import { Button, Modal, ToolTip, RemoteLottie, Loading } from 'components/common'
import { useModals } from 'hooks'
import MultiplierBadges from './MultiplierBadges/MultiplierBadges'
import UnbondModal from './UnbondModal/UnbondModal'

Expand All @@ -18,6 +19,7 @@ const WalletTokenModal = ({ accountId, claimableWalletToken, rewards, network })
const [isUnbondModalVisible, setIsUnbondModalVisible] = useState(false)
const provider = rpcProviders['ethereum-ambire-earn']
const { stakedAmount, isLoading } = useStakedWalletToken({ accountId, provider })
const { hideModal } = useModals()

const hideUnbondModal = () => setIsUnbondModalVisible(false)

Expand All @@ -38,7 +40,21 @@ const WalletTokenModal = ({ accountId, claimableWalletToken, rewards, network })

const { walletTokenAPYPercentage, adxTokenAPYPercentage, xWALLETAPYPercentage } = rewards

const claimWithBurn = () => claimEarlyRewards(false)
const claimWithBurn = () => {
claimEarlyRewards(false)
hideUnbondModal()
hideModal()
}

const claimEarly = () => {
claimEarlyRewards(true)
hideModal()
}

const claimWithVesting = () => {
claimVesting()
hideModal()
}

const eligibilityLeft = MIN_ELIGIBLE_USD - rewards.balance.balanceInUSD
const isEligible = eligibilityLeft <= 0
Expand Down Expand Up @@ -188,7 +204,7 @@ const WalletTokenModal = ({ accountId, claimableWalletToken, rewards, network })
<Button
className={styles.fullWidthButton}
variant="terniaryGradient"
onClick={claimEarlyRewards}
onClick={claimEarly}
disabled={!!(claimDisabledReason || disabledReason)}
>
CLAIM IN xWALLET
Expand Down Expand Up @@ -237,7 +253,7 @@ const WalletTokenModal = ({ accountId, claimableWalletToken, rewards, network })
<Button
variant="primaryGradient"
className={styles.fullWidthButton}
onClick={claimVesting}
onClick={claimWithVesting}
disabled={!!disabledReason}
>
Claim
Expand Down

0 comments on commit d53b73a

Please sign in to comment.