Skip to content

Commit

Permalink
update basepayment page and makeDefaultPaymentMethod to no longer req…
Browse files Browse the repository at this point in the history
…uire passwords
  • Loading branch information
NikkiWines committed Jul 13, 2023
1 parent a2918cf commit bfaf167
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
5 changes: 1 addition & 4 deletions src/libs/actions/PaymentMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,16 @@ function getMakeDefaultPaymentOnyxData(bankAccountID, fundID, previousPaymentMet
/**
* Sets the default bank account or debit card for an Expensify Wallet
*
* @param {String} password
* @param {Number} bankAccountID
* @param {Number} fundID
* @param {Object} previousPaymentMethod
* @param {Object} currentPaymentMethod
*
*/
function makeDefaultPaymentMethod(password, bankAccountID, fundID, previousPaymentMethod, currentPaymentMethod) {
function makeDefaultPaymentMethod(bankAccountID, fundID, previousPaymentMethod, currentPaymentMethod) {
API.write(
'MakeDefaultPaymentMethod',
{
password,
bankAccountID,
fundID,
},
Expand Down Expand Up @@ -162,7 +160,6 @@ function addPaymentCard(params) {
addressZip: params.addressZipCode,
currency: CONST.CURRENCY.USD,
isP2PDebitCard: true,
password: params.password,
},
{
optimisticData: [
Expand Down
20 changes: 3 additions & 17 deletions src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class BasePaymentsPage extends React.Component {
this.hideDefaultDeleteMenu = this.hideDefaultDeleteMenu.bind(this);
this.makeDefaultPaymentMethod = this.makeDefaultPaymentMethod.bind(this);
this.deletePaymentMethod = this.deletePaymentMethod.bind(this);
this.hidePasswordPrompt = this.hidePasswordPrompt.bind(this);
this.navigateToTransferBalancePage = this.navigateToTransferBalancePage.bind(this);
this.setMenuPosition = this.setMenuPosition.bind(this);
this.listHeaderComponent = this.listHeaderComponent.bind(this);
Expand Down Expand Up @@ -102,8 +101,6 @@ class BasePaymentsPage extends React.Component {
// Close corresponding selected payment method modals which are open
if (this.state.shouldShowDefaultDeleteMenu) {
this.hideDefaultDeleteMenu();
} else if (this.state.shouldShowPasswordPrompt) {
this.hidePasswordPrompt();
}
}
}
Expand Down Expand Up @@ -288,27 +285,16 @@ class BasePaymentsPage extends React.Component {
});
}

hidePasswordPrompt(shouldClearSelectedData = true) {
this.setState({shouldShowPasswordPrompt: false});
if (shouldClearSelectedData) {
this.resetSelectedPaymentMethodData();
}

// Due to iOS modal freeze issue, password modal freezes the app when closed.
// LayoutAnimation undoes the running animation.
LayoutAnimation.configureNext(LayoutAnimation.create(50, LayoutAnimation.Types.easeInEaseOut, LayoutAnimation.Properties.opacity));
}

makeDefaultPaymentMethod(password = '') {
makeDefaultPaymentMethod() {
// Find the previous default payment method so we can revert if the MakeDefaultPaymentMethod command errors
const paymentMethods = PaymentUtils.formatPaymentMethods(this.props.bankAccountList, this.props.cardList);

const previousPaymentMethod = _.find(paymentMethods, (method) => method.isDefault);
const currentPaymentMethod = _.find(paymentMethods, (method) => method.methodID === this.state.methodID);
if (this.state.selectedPaymentMethodType === CONST.PAYMENT_METHODS.BANK_ACCOUNT) {
PaymentMethods.makeDefaultPaymentMethod(password, this.state.selectedPaymentMethod.bankAccountID, null, previousPaymentMethod, currentPaymentMethod);
PaymentMethods.makeDefaultPaymentMethod(this.state.selectedPaymentMethod.bankAccountID, null, previousPaymentMethod, currentPaymentMethod);
} else if (this.state.selectedPaymentMethodType === CONST.PAYMENT_METHODS.DEBIT_CARD) {
PaymentMethods.makeDefaultPaymentMethod(password, null, this.state.selectedPaymentMethod.fundID, previousPaymentMethod, currentPaymentMethod);
PaymentMethods.makeDefaultPaymentMethod(null, this.state.selectedPaymentMethod.fundID, previousPaymentMethod, currentPaymentMethod);
}
this.resetSelectedPaymentMethodData();
}
Expand Down

0 comments on commit bfaf167

Please sign in to comment.