Skip to content

Commit

Permalink
fix: set allowed flag only in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
tnrdd committed Oct 10, 2022
1 parent 05832bf commit bb915e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 5 additions & 4 deletions components/ApproveButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export function ApproveButton(props: ApproveButtonProps) {
);
setIsActing(false);
setDidFail(true);
setIsAllowed(false);
return false;
}

Expand Down Expand Up @@ -125,7 +124,6 @@ export function ApproveButton(props: ApproveButtonProps) {
);
setIsActing(false);
setDidFail(true);
setIsAllowed(false);
return false;
}

Expand Down Expand Up @@ -153,7 +151,6 @@ export function ApproveButton(props: ApproveButtonProps) {
if (requiredPayment && BigNumber.from(allowance).lt(requiredPayment)) {
_approvals.push(approvePayment);
_approvalStr = `Allow ${PAYMENT_TOKEN} Transfer`;
setIsAllowed(false);
}

// Check flow allowance
Expand All @@ -177,8 +174,12 @@ export function ApproveButton(props: ApproveButtonProps) {
_approvals.length > 1
? `Allow ${PAYMENT_TOKEN} Transfer + Stream`
: `Allow ${PAYMENT_TOKEN} Stream`;
} else {
}

if (_approvals.length === 0) {
setIsAllowed(true);
} else {
setIsAllowed(false);
}

setApprovals(_approvals);
Expand Down
8 changes: 7 additions & 1 deletion components/PerformButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ export function PerformButton(props: PerformButtonProps) {

return (
<Button
variant={isAllowed || isDisabled ? "success" : "info"}
variant={
!isAllowed
? "info"
: buttonText === "Reject Bid"
? "danger"
: "success"
}
className="w-100"
onClick={() => submit()}
disabled={isDisabled || !isAllowed}
Expand Down

0 comments on commit bb915e7

Please sign in to comment.