Skip to content

Commit

Permalink
Merge pull request #4242 from Expensify/stites-revertAddPaymentButton…
Browse files Browse the repository at this point in the history
…Changes

Revert add payment button changes
  • Loading branch information
Gonals authored Jul 29, 2021
2 parents 6f1b536 + 0f61e96 commit f4ea025
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 36 deletions.
1 change: 1 addition & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export default {
payPalMe: 'PayPal.me/',
yourPayPalUsername: 'Your PayPal username',
addPayPalAccount: 'Add PayPal Account',
editPayPalAccount: 'Update PayPal Account',
growlMessageOnSave: 'Your PayPal username was successfully added',
},
paymentsPage: {
Expand Down
3 changes: 2 additions & 1 deletion src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ export default {
enterYourUsernameToGetPaidViaPayPal: 'Escribe tu nombre de usuario para que otros puedan pagarte a través de PayPal.',
payPalMe: 'PayPal.me/',
yourPayPalUsername: 'Tu usuario de PayPal',
addPayPalAccount: 'Agregar Cuenta de Paypal',
addPayPalAccount: 'Agregar cuenta de PayPal',
editPayPalAccount: 'Actualizar cuenta de PayPal',
},
paymentsPage: {
paymentMethodsTitle: 'Métodos de pago',
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function getBetas() {
function getUserDetails() {
API.Get({
returnValueList: 'account, loginList, nameValuePairs',
nvpNames: [CONST.NVP.BLOCKED_FROM_CONCIERGE, CONST.NVP.PAYPAL_ME_ADDRESS].join(','),
nvpNames: CONST.NVP.PAYPAL_ME_ADDRESS,
})
.then((response) => {
// Update the User onyx key
Expand Down
9 changes: 6 additions & 3 deletions src/pages/settings/Payments/AddPayPalMePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import HeaderWithCloseButton from '../../../components/HeaderWithCloseButton';
import Text from '../../../components/Text';
import ScreenWrapper from '../../../components/ScreenWrapper';
import NameValuePair from '../../../libs/actions/NameValuePair';
import {getUserDetails} from '../../../libs/actions/User';
import getPaymentMethods from '../../../libs/actions/PaymentMethods';
import Navigation from '../../../libs/Navigation/Navigation';
import styles from '../../../styles/styles';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
Expand Down Expand Up @@ -42,7 +42,7 @@ class AddPayPalMePage extends React.Component {
}

componentDidMount() {
getUserDetails();
getPaymentMethods();
}

componentDidUpdate(prevProps) {
Expand All @@ -59,6 +59,7 @@ class AddPayPalMePage extends React.Component {
setPayPalMeUsername() {
NameValuePair.set(CONST.NVP.PAYPAL_ME_ADDRESS, this.state.payPalMeUsername, ONYXKEYS.NVP_PAYPAL_ME_ADDRESS);
Growl.show(this.props.translate('addPayPalMePage.growlMessageOnSave'), CONST.GROWL.SUCCESS, 3000);
Navigation.navigate(ROUTES.SETTINGS_PAYMENTS);
}

render() {
Expand Down Expand Up @@ -102,7 +103,9 @@ class AddPayPalMePage extends React.Component {
onPress={this.setPayPalMeUsername}
pressOnEnter
style={[styles.mt3]}
text={this.props.translate('addPayPalMePage.addPayPalAccount')}
text={this.props.payPalMeUsername
? this.props.translate('addPayPalMePage.editPayPalAccount')
: this.props.translate('addPayPalMePage.addPayPalAccount')}
/>
</FixedFooter>
</KeyboardAvoidingView>
Expand Down
21 changes: 8 additions & 13 deletions src/pages/settings/Payments/PaymentMethodList.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,14 @@ class PaymentMethodList extends Component {
});
}

// Don't show Add Payment Method button if user provided details for all possible payment methods.
// Right now only available method is Paypal.me
// When there is a new payment method, it needs to be added to following if condition.
if (!this.props.payPalMeUsername) {
combinedPaymentMethods.push({
type: MENU_ITEM,
title: this.props.translate('paymentMethodList.addPaymentMethod'),
icon: Plus,
onPress: e => this.props.onPress(e),
key: 'addPaymentMethodButton',
disabled: this.props.isLoadingPayments,
});
}
combinedPaymentMethods.push({
type: MENU_ITEM,
title: this.props.translate('paymentMethodList.addPaymentMethod'),
icon: Plus,
onPress: e => this.props.onPress(e),
key: 'addPaymentMethodButton',
disabled: this.props.isLoadingPayments,
});

return combinedPaymentMethods;
}
Expand Down
23 changes: 5 additions & 18 deletions src/pages/settings/Payments/PaymentsPage.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import React from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import ONYXKEYS from '../../../ONYXKEYS';
import PaymentMethodList from './PaymentMethodList';
import ROUTES from '../../../ROUTES';
import HeaderWithCloseButton from '../../../components/HeaderWithCloseButton';
Expand All @@ -23,9 +20,6 @@ import CurrentWalletBalance from '../../../components/CurrentWalletBalance';
const PAYPAL = 'payPalMe';

const propTypes = {
/** User's paypal.me username if they have one */
payPalMeUsername: PropTypes.string,

...withLocalizePropTypes,
};

Expand Down Expand Up @@ -129,13 +123,11 @@ class PaymentsPage extends React.Component {
left: this.state.anchorPositionLeft,
}}
>
{!this.props.payPalMeUsername && (
<MenuItem
title="PayPal.me"
icon={PayPal}
onPress={() => this.addPaymentMethodTypePressed(PAYPAL)}
/>
)}
<MenuItem
title="PayPal.me"
icon={PayPal}
onPress={() => this.addPaymentMethodTypePressed(PAYPAL)}
/>
</Popover>
</KeyboardAvoidingView>
</ScreenWrapper>
Expand All @@ -149,9 +141,4 @@ PaymentsPage.displayName = 'PaymentsPage';

export default compose(
withLocalize,
withOnyx({
payPalMeUsername: {
key: ONYXKEYS.NVP_PAYPAL_ME_ADDRESS,
},
}),
)(PaymentsPage);

0 comments on commit f4ea025

Please sign in to comment.