Skip to content

Commit

Permalink
Don't show 'Make default payment method' button if it's the only paym…
Browse files Browse the repository at this point in the history
…ent method or if it's already the default
  • Loading branch information
Shahidullah-Muffakir committed Nov 22, 2024
1 parent b14f4f9 commit c7c9f5e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/pages/settings/Wallet/WalletPage/WalletPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,22 @@ function WalletPage({shouldListenForResize = false}: WalletPageProps) {
}
}
}, [hideDefaultDeleteMenu, paymentMethod.methodID, paymentMethod.selectedPaymentMethodType, bankAccountList, fundList, shouldShowDefaultDeleteMenu]);
// Don't show "Make default payment method" button if it's the only payment method or if it's already the default
const isCurrentPaymentMethodDefault = () => {
const hasMultiplePaymentMethods = PaymentUtils.formatPaymentMethods(bankAccountList ?? {}, fundList ?? {}, styles).length > 1;
if (hasMultiplePaymentMethods) {
if (paymentMethod.formattedSelectedPaymentMethod.type === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT) {
return paymentMethod.selectedPaymentMethod.bankAccountID === userWallet?.walletLinkedAccountID;
}
if (paymentMethod.formattedSelectedPaymentMethod.type === CONST.PAYMENT_METHODS.DEBIT_CARD) {
return paymentMethod.selectedPaymentMethod.fundID === userWallet?.walletLinkedAccountID;
}
}
return true;
};

const shouldShowMakeDefaultButton =
!paymentMethod.isSelectedPaymentMethodDefault &&
!isCurrentPaymentMethodDefault() &&
!(paymentMethod.formattedSelectedPaymentMethod.type === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && paymentMethod.selectedPaymentMethod.type === CONST.BANK_ACCOUNT.TYPE.BUSINESS);

// Determines whether or not the modal popup is mounted from the bottom of the screen instead of the side mount on Web or Desktop screens
Expand Down

0 comments on commit c7c9f5e

Please sign in to comment.