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

Fix make default payment #8410

Merged
merged 5 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion src/pages/settings/Payments/PaymentMethodList.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class PaymentMethodList extends Component {
combinedPaymentMethods = _.map(combinedPaymentMethods, paymentMethod => ({
...paymentMethod,
type: MENU_ITEM,
onPress: e => this.props.onPress(e, paymentMethod.accountType, paymentMethod.accountData),
onPress: e => this.props.onPress(e, paymentMethod.accountType, paymentMethod.accountData, paymentMethod.isDefault),
iconFill: this.isPaymentMethodActive(paymentMethod) ? StyleUtils.getIconFillColor(CONST.BUTTON_STATES.PRESSED) : null,
wrapperStyle: this.isPaymentMethodActive(paymentMethod) ? [StyleUtils.getButtonBackgroundColorStyle(CONST.BUTTON_STATES.PRESSED)] : null,
}));
Expand Down
10 changes: 7 additions & 3 deletions src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class BasePaymentsPage extends React.Component {
shouldShowDefaultDeleteMenu: false,
shouldShowPasswordPrompt: false,
shouldShowConfirmPopover: false,
isSelectedPaymentMethodDefault: false,
selectedPaymentMethod: {},
formattedSelectedPaymentMethod: {},
anchorPositionTop: 0,
Expand Down Expand Up @@ -112,8 +113,9 @@ class BasePaymentsPage extends React.Component {
* @param {Object} nativeEvent
* @param {String} accountType
* @param {String} account
* @param {Boolean} isDefault
*/
paymentMethodPressed(nativeEvent, accountType, account) {
paymentMethodPressed(nativeEvent, accountType, account, isDefault) {
const position = getClickedElementLocation(nativeEvent);
this.setState({
addPaymentMethodButton: nativeEvent,
Expand Down Expand Up @@ -143,6 +145,7 @@ class BasePaymentsPage extends React.Component {
};
}
this.setState({
isSelectedPaymentMethodDefault: isDefault,
shouldShowDefaultDeleteMenu: true,
selectedPaymentMethod: account,
selectedPaymentMethodType: accountType,
Expand Down Expand Up @@ -229,6 +232,7 @@ class BasePaymentsPage extends React.Component {

render() {
const isPayPalMeSelected = this.state.formattedSelectedPaymentMethod.type === CONST.PAYMENT_METHODS.PAYPAL;
const isShowButtonMakeDefaultPayment = !this.state.isSelectedPaymentMethodDefault && Permissions.canUseWallet(this.props.betas) && !isPayPalMeSelected;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const isShowButtonMakeDefaultPayment = !this.state.isSelectedPaymentMethodDefault && Permissions.canUseWallet(this.props.betas) && !isPayPalMeSelected;
const shouldShowMakeDefaultButton = !this.state.isSelectedPaymentMethodDefault && Permissions.canUseWallet(this.props.betas) && !isPayPalMeSelected;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated!

Copy link
Member

@parasharrajat parasharrajat Apr 5, 2022

Choose a reason for hiding this comment

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

Updated name does not match with requested change.


// 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
const isPopoverBottomMount = this.state.anchorPositionTop === 0 || this.props.isSmallScreenWidth;
Expand Down Expand Up @@ -318,7 +322,7 @@ class BasePaymentsPage extends React.Component {
interactive={false}
/>
)}
{Permissions.canUseWallet(this.props.betas) && !isPayPalMeSelected && (
{isShowButtonMakeDefaultPayment && (
<TouchableOpacity
onPress={() => {
this.setState({
Expand Down Expand Up @@ -356,7 +360,7 @@ class BasePaymentsPage extends React.Component {
style={[
styles.button,
styles.buttonDanger,
Permissions.canUseWallet(this.props.betas) && !isPayPalMeSelected && styles.mt4,
isShowButtonMakeDefaultPayment && styles.mt4,
styles.alignSelfCenter,
styles.w100,
]}
Expand Down