Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert add payment button changes #4242

Merged
merged 7 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,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 @@ -231,7 +231,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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not capitalize Cuenta here, since we don't capitalize usuario above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Updated!

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 @@ -130,19 +130,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);