Skip to content

Commit

Permalink
fix for delete from BA
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerGery committed Jan 21, 2024
1 parent 61554a9 commit 7cbc51d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
11 changes: 9 additions & 2 deletions examples/client/Locomotion/src/context/newRideContext/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ const RidePageContextProvider = ({ children }: {
const FAILED_ESTIMATIONS_ACTIONS = {
[ESTIMATION_ERRORS['RIDE_VALIDATION:SOME_STOP_POINTS_ARE_OUT_OF_TERRITORY']]: () => changeBsPage(BS_PAGES.NOT_IN_TERRITORY),
[ESTIMATION_ERRORS.FIRST_STOP_POINT_NOT_IN_TERRITORY]: () => changeBsPage(BS_PAGES.PICKUP_NOT_IN_TERRITORY),
[ESTIMATION_ERRORS.CLIENT_NOT_IN_BUSINESS_ACCOUNT]: async () => {
await StorageService.delete('lastBusinessAccountId');
setBusinessAccountId(null);
},
};


Expand Down Expand Up @@ -444,8 +448,11 @@ const RidePageContextProvider = ({ children }: {
} catch (e: any) {
Mixpanel.setEvent('service estimations failed', { status: e?.response?.status });
if (throwError) {
if (FAILED_ESTIMATIONS_ACTIONS[e?.response?.data?.errors[0]]) {
FAILED_ESTIMATIONS_ACTIONS[e?.response?.data?.errors[0]]();
const error = e?.response?.data?.errors[0];
const errorHandleFunction = FAILED_ESTIMATIONS_ACTIONS[error];
if (errorHandleFunction) {
Mixpanel.setEvent('service estimations failed with error reason', { error });
await errorHandleFunction();
} else {
cleanRideState();
setRidePopup(RIDE_POPUPS.FAILED_SERVICE_REQUEST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getLocationTimezone } from './api';
export const ESTIMATION_ERRORS = {
'RIDE_VALIDATION:SOME_STOP_POINTS_ARE_OUT_OF_TERRITORY': 'RIDE_VALIDATION:SOME_STOP_POINTS_ARE_OUT_OF_TERRITORY',
FIRST_STOP_POINT_NOT_IN_TERRITORY: 'FIRST_STOP_POINT_NOT_IN_TERRITORY',
CLIENT_NOT_IN_BUSINESS_ACCOUNT: 'BUSINESS_ACCOUNT_CLIENT_NOT_FOUND',
};

export const RIDE_FAILED_REASONS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const PaymentMethodPopup = ({
selectedBusinessAccountId ? PAYMENT_MODES.BUSINESS : PAYMENT_MODES.PERSONAL,
);
const isBusinessMode = activePaymentTab === PAYMENT_MODES.BUSINESS;

const personalPaymentMethods = [
...usePayments.paymentMethods,
...(showCash ? [cashPaymentMethod] : []),
Expand All @@ -80,6 +81,13 @@ const PaymentMethodPopup = ({
usePayments.loadCustomer();
}, []);

useEffect(() => {
if (!usePayments.businessPaymentMethods?.length
&& activePaymentTab === PAYMENT_MODES.BUSINESS) {
setActivePaymentTab(PAYMENT_MODES.PERSONAL);
}
}, [usePayments.businessPaymentMethods]);

useEffect(() => {
const updateDefaultPaymentMethod = async () => {
if (selected) {
Expand Down

0 comments on commit 7cbc51d

Please sign in to comment.