disable review button if no card saved also some cleanup #6535

Merged
mayeaux merged 2 commits from hotfix-to-disable-review-button into master 2021-07-19 03:49:21 +02:00
Showing only changes of commit 26594015ce - Show all commits

View file

@ -34,7 +34,7 @@ type Props = {
uri: string,
onTipErrorChange: (string) => void,
activeTab: string,
shouldDisableReviewButton: (string) => void
shouldDisableReviewButton: (boolean) => void
};
function WalletTipAmountSelector(props: Props) {
@ -45,24 +45,22 @@ function WalletTipAmountSelector(props: Props) {
const [canReceiveFiatTip, setCanReceiveFiatTip] = React.useState(); // dont persist because it needs to be calc'd per creator
const [hasCardSaved, setHasSavedCard] = usePersistedState('comment-support:hasCardSaved', false);
// if it's fiat but there's no card saved OR the creator can't receive fiat tips
const shouldDisableFiatSelectors = (activeTab === TAB_FIAT && (!hasCardSaved || !canReceiveFiatTip));
/**
* whether tip amount selection/review functionality should be disabled
* @param [amount] LBC amount (optional)
* @returns {boolean}
*/
function shouldDisableAmountSelector(amount) {
const shouldDisable =
// if it's LBC but the balance isn't enough
(amount > balance && activeTab !== TAB_FIAT) ||
// if it's fiat but there's no card saved OR the creator can't receive fiat tips
(activeTab === TAB_FIAT && (!hasCardSaved || !canReceiveFiatTip));
shouldDisableReviewButton(shouldDisable);
return shouldDisable;
// if it's LBC but the balance isn't enough, or fiat conditions met
// $FlowFixMe
return (amount > balance && activeTab !== TAB_FIAT) || shouldDisableFiatSelectors;
}
shouldDisableReviewButton(shouldDisableFiatSelectors);
jessopb commented 2021-07-18 23:23:39 +02:00 (Migrated from github.com)
Review

if you supply an inititial value to useState(false), flow wouldn't complain here.

if you supply an inititial value to useState(false), flow wouldn't complain here.
// setup variables for tip API
let channelClaimId, tipChannelName;
// if there is a signing channel it's on a file