Skip to content

Commit

Permalink
fix chosen method
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerGery committed Jan 21, 2024
1 parent f312404 commit bc6dbc6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ const RideOptions = () => {
}}
showCash={showCash}
showOffline={showOffline}
selected={ride?.paymentMethodId
&& usePayments.paymentMethods.find((pm: any) => ride.paymentMethodId === pm.id)
? ride.paymentMethodId : defaultPaymentMethod?.id}
selected={ride?.paymentMethodId || defaultPaymentMethod?.id}
rideFlow
isVisible={popupToShow === 'payment'}
onCancel={() => clearPopup()}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable no-unused-expressions */
import React, { useContext, useEffect, useState } from 'react';
import { View } from 'react-native';
import PropTypes from 'prop-types';
import Modal from 'react-native-modal';
import { useNavigation } from '@react-navigation/native';
Expand Down Expand Up @@ -84,7 +83,11 @@ const PaymentMethodPopup = ({
useEffect(() => {
const updateDefaultPaymentMethod = async () => {
if (selected) {
setSelectedPaymentId(selected);
if (selected === offlinePaymentMethod.id && selectedBusinessAccountId) {
setSelectedPaymentId(selectedBusinessAccountId);
} else {
setSelectedPaymentId(selected);
}
} else {
const paymentMethod = await usePayments.getClientDefaultMethod();
if (paymentMethod?.id) {
Expand Down Expand Up @@ -149,8 +152,6 @@ const PaymentMethodPopup = ({
<Title>{i18n.t('popups.choosePaymentMethod.title')}</Title>
<CloseButton onPress={async () => {
onCancel();
setSelectedPaymentId(selected
|| (await usePayments.getClientDefaultMethod())?.id);
rideFlow
? navigationService.navigate(MAIN_ROUTES.HOME)
: navigationService.navigate(MAIN_ROUTES.PAYMENT);
Expand Down

0 comments on commit bc6dbc6

Please sign in to comment.