Skip to content

Commit

Permalink
refactor: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscotobar committed Nov 28, 2024
1 parent 342a5b1 commit 7e633be
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
19 changes: 5 additions & 14 deletions src/app/collective-rewards/rewards/builders/ClaimableRewards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { withSpinner } from '@/components/LoadingSpinner/withLoadingSpinner'
import { usePricesContext } from '@/shared/context/PricesContext'
import { FC } from 'react'
import { Address } from 'viem'
import { Popover } from '../../../../components/Popover'

type TokenRewardsMetricsProps = {
builder: Address
Expand Down Expand Up @@ -58,19 +57,11 @@ const TokenRewardsMetrics: FC<TokenRewardsMetricsProps> = ({
fiatAmount,
isLoading: rewardsLoading,
children: (
<Popover
content={
<div className="text-[12px] font-bold mb-1">
<p data-testid="adjustBackerRewardPctTooltip">You cannot be paused to claim rewards</p>
</div>
}
size="small"
position="top"
trigger="hover"
disabled={!isPaused}
>
<ClaimYourRewardsButton onClick={() => claimRewards()} disabled={!isClaimable || isPaused} />
</Popover>
<ClaimYourRewardsButton
onClick={() => claimRewards()}
disabled={!isClaimable || isPaused}
isPaused={isPaused}
/>
),
})
}
Expand Down
1 change: 1 addition & 0 deletions src/app/collective-rewards/rewards/builders/Rewards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const RewardsContent: FC<RewardsProps> = props => {
<p data-testid="adjustBackerRewardPctTooltip">You cannot be paused to claim rewards</p>
</div>
}
className="w-full"
size="small"
position="top"
trigger="hover"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import { GaugeAbi } from '@/lib/abis/v2/GaugeAbi'
import { Address } from 'viem'
import { useWaitForTransactionReceipt, useWriteContract } from 'wagmi'
import { useGetBuilderRewards } from '@/app/collective-rewards/rewards'
import { useBuilderContext } from '../../../user'
import { useBuilderContext } from '@/app/collective-rewards/user'

const useClaimBuilderReward = (builder: Address, gauge: Address, rewardToken?: Address) => {
const { writeContractAsync, error: executionError, data: hash, isPending } = useWriteContract()
const { getBuilderByAddress } = useBuilderContext()

const claimingBuilder = getBuilderByAddress(builder)
console.log('🚀 ~ useClaimBuilderReward ~ claimingBuilder:', claimingBuilder)
const isPaused = !!claimingBuilder?.stateFlags?.paused
const isPaused = claimingBuilder?.stateFlags?.paused ?? false

const { isLoading, isSuccess, data, error: receiptError } = useWaitForTransactionReceipt({ hash })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ const ClaimYourRewardsSvg = () => (
</svg>
)

export const ClaimYourRewardsButton: FC<Pick<ButtonProps, 'onClick' | 'disabled'>> = buttonProps => (
export const ClaimYourRewardsButton: FC<
Pick<ButtonProps, 'onClick' | 'disabled'> & { isPaused?: boolean }
> = ({ isPaused, ...buttonProps }) => (
<div className="self-start justify-self-end pt-[10px]">
<Popover
content={
<div className="text-[12px] font-bold mb-1">
<p data-testid="claimYouRewardsButtonTooltip">Claim your rewards</p>
<p data-testid="claimYouRewardsButtonTooltip">
{isPaused ? 'You cannot be paused to claim rewards' : 'Claim your rewards'}
</p>
</div>
}
size="small"
Expand Down

0 comments on commit 7e633be

Please sign in to comment.