Skip to content

Commit

Permalink
disable yield collect buttons if no yield claimable
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-d committed Nov 26, 2024
1 parent d022721 commit f60b4d6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
13 changes: 10 additions & 3 deletions web/src/app/stake/MyPositions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ export const MyPositions = () => {
campaignTokenPrices,
getTokenFromAddress,
]);
const collectAllYieldButtonDisabled =
!!collectData ||
isCollectPending ||
isLeoRewardsOnly ||
unclaimedRewards === "$0.00";

const collectAll = useCallback(() => {
// for all positions that are in leo, call leo collect
Expand Down Expand Up @@ -494,7 +499,7 @@ export const MyPositions = () => {
<Button
className="w-full text-3xs text-black md:text-xs"
variant={collectError ? "destructive" : "iridescent"}
disabled={!!collectData || isCollectPending || isLeoRewardsOnly}
disabled={collectAllYieldButtonDisabled}
size="sm"
onClick={() => collectAll()}
>
Expand All @@ -506,13 +511,15 @@ export const MyPositions = () => {
? "Claimed!"
: isCollectPending
? "Claiming..."
: "Claim All Yield"}
: unclaimedRewards === "$0.00"
? "No Yield to Claim"
: "Claim All Yield"}
</Button>
<Badge
variant={collectError ? "destructive" : "iridescent"}
className={cn(
"-mt-2 gap-2 border-2 border-black text-3xs",
(collectData || isCollectPending || isLeoRewardsOnly) &&
collectAllYieldButtonDisabled &&
"pointer-events-none opacity-70",
)}
>
Expand Down
15 changes: 9 additions & 6 deletions web/src/app/stake/pool/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ export default function PoolPage() {
tokenPrice,
campaignTokenPrices,
]);
const collectYieldButtonDisabled =
!!collectData ||
isCollectPending ||
isLeoRewardsOnly ||
unclaimedRewards === "$0.00";

const collect = useCallback(
(id: bigint) => {
Expand Down Expand Up @@ -830,11 +835,7 @@ export default function PoolPage() {
variant={collectError ? "destructive" : "secondary"}
className="h-[19px] w-[75px] select-none px-[27px] py-[5px] md:h-[22px] md:w-[92px]"
size="sm"
disabled={
!!collectData ||
isCollectPending ||
isLeoRewardsOnly
}
disabled={collectYieldButtonDisabled}
onClick={() =>
positionId && collect(BigInt(positionId))
}
Expand All @@ -848,7 +849,9 @@ export default function PoolPage() {
? "Claimed!"
: isCollectPending
? "Claiming..."
: "Claim Yield"}
: unclaimedRewards === "$0.00"
? "No Yield to Claim"
: "Claim Yield"}
</div>
</Button>
</div>
Expand Down

0 comments on commit f60b4d6

Please sign in to comment.