diff --git a/src/app/collective-rewards/rewards/ClaimableRewards.tsx b/src/app/collective-rewards/rewards/ClaimableRewards.tsx index 6d19843a..3f0ed0f6 100644 --- a/src/app/collective-rewards/rewards/ClaimableRewards.tsx +++ b/src/app/collective-rewards/rewards/ClaimableRewards.tsx @@ -1,19 +1,19 @@ -import { FC, useEffect, useState } from 'react' -import { Address } from 'viem' -import { usePricesContext } from '@/shared/context/PricesContext' import { formatMetrics, + MetricsCard, + MetricsCardTitle, + TokenMetricsCardRow, useClaimBuilderRewards, - useGetBuilderRewards, useClaimStateReporting, - MetricsCardWithSpinner, - TokenMetricsCardRow, - MetricsCardTitle, + useGetBuilderRewards, } from '@/app/collective-rewards/rewards' +import { useHandleErrors } from '@/app/collective-rewards/utils' import { formatBalanceToHuman } from '@/app/user/Balances/balanceUtils' +import { withSpinner } from '@/components/LoadingSpinner/withLoadingSpinner' import { Popover } from '@/components/Popover' -import { useHandleErrors } from '@/app/collective-rewards/utils' -import { Button } from '@/components/Button' +import { usePricesContext } from '@/shared/context/PricesContext' +import { FC } from 'react' +import { Address } from 'viem' const ClaimYourRewardsSvg = () => ( @@ -37,14 +37,12 @@ type RewardsTokenMetricsProps = { gauge: Address token: Token currency?: string - setState: (state: { isLoading: boolean }) => void } const RewardsTokenMetrics: FC = ({ builder, gauge, token: { address, symbol }, - setState, currency = 'USD', }) => { const { prices } = usePricesContext() @@ -54,7 +52,7 @@ const RewardsTokenMetrics: FC = ({ isLoading: isLoadingRewards, error: rewardsError, } = useGetBuilderRewards(address, gauge) - useHandleErrors([{ error: rewardsError, title: 'Error loading rewards' }]) + useHandleErrors({ error: rewardsError, title: 'Error loading rewards' }) const tokenPrice = prices[symbol]?.price ?? 0 @@ -69,28 +67,29 @@ const RewardsTokenMetrics: FC = ({ useClaimStateReporting({ ...claimTx, error: rewardsError ?? claimTx.error }) - useEffect(() => { - setState({ isLoading: isLoadingRewards }) - }, [isLoadingRewards, setState]) - - return ( - - -

Claim your rewards

- - } - size="small" - position="top" - trigger="hover" - > - - - - ) + return withSpinner(TokenMetricsCardRow)({ + amount: rewardMetrics.amount, + fiatAmount: rewardMetrics.fiatAmount, + isLoading: isLoadingRewards, + children: ( +
+ +

Claim your rewards

+
+ } + size="small" + position="top" + trigger="hover" + > + + + + ), + }) } type ClaimableRewardsProps = { @@ -103,14 +102,11 @@ type ClaimableRewardsProps = { } export const ClaimableRewards: FC = ({ data, ...rest }) => { - const [{ isLoading: isLoadingRif }, setRifState] = useState({ isLoading: false }) - const [{ isLoading: isLoadingRbtc }, setRbtcState] = useState({ isLoading: false }) - return ( - + - setRifState} /> - setRbtcState} /> - + + + ) }