From 69130ef0c6164bb71ff73878d50f698778faec61 Mon Sep 17 00:00:00 2001 From: Sephi Nahmias <24208414+sephina@users.noreply.github.com> Date: Sun, 25 Feb 2024 12:34:22 +0200 Subject: [PATCH 1/4] scroll cancellation reasons --- .../popups/CancellationReasonsPopup/index.tsx | 73 ++++++++++--------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/examples/client/Locomotion/src/popups/CancellationReasonsPopup/index.tsx b/examples/client/Locomotion/src/popups/CancellationReasonsPopup/index.tsx index 36af2b361..0b0fd4a2d 100644 --- a/examples/client/Locomotion/src/popups/CancellationReasonsPopup/index.tsx +++ b/examples/client/Locomotion/src/popups/CancellationReasonsPopup/index.tsx @@ -1,5 +1,6 @@ import React, { useContext, useEffect, useState } from 'react'; import Modal from 'react-native-modal'; +import { ScrollView } from 'react-native-gesture-handler'; import CloseButton from '../../Components/CloseButton'; import CancellationReasonsProvider, { CancellationReasonsContext } from '../../context/cancellation-reasons'; import RoundedButton from '../../Components/RoundedButton'; @@ -76,39 +77,45 @@ const CancellationReasonsPopup = ({ cancellationReasons?.length > 0 ? ( - - - - {i18n.t('popups.cancellationReasons.title')} - - {i18n.t('popups.cancellationReasons.subTitle')} - - - {isLoading - ? ( - - - - ) - : cancellationReasons.map(cr => ( - onCancellationReasonClick(cr.id)} - testID={`cancellationReason-${cr.category}`} - > - - - {i18n.t(`cancellationReasons.${cr.value}`, cr.value)} - - - - ))} - + + + + + {i18n.t('popups.cancellationReasons.title')} + + {i18n.t('popups.cancellationReasons.subTitle')} + + + {isLoading + ? ( + + + + ) + : ( + cancellationReasons.map(cr => ( + onCancellationReasonClick(cr.id)} + testID={`cancellationReason-${cr.category}`} + > + + + + {i18n.t(`cancellationReasons.${cr.value}`, cr.value)} + + + + )) + ) + } + + ) : null From 8f5b00436b692f0690d6dab43c8422096ca58731 Mon Sep 17 00:00:00 2001 From: hilat-autofleet Date: Sun, 25 Feb 2024 12:56:13 +0200 Subject: [PATCH 2/4] PassengersCounter previous selected value --- .../Locomotion/src/Components/SelectModal/index.tsx | 11 +++++++++-- .../Locomotion/src/context/newRideContext/index.tsx | 6 ++++-- .../RideButtons/PassengersCounter/index.tsx | 5 ++++- .../RideDrawer/RideOptions/RideButtons/index.tsx | 2 ++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/examples/client/Locomotion/src/Components/SelectModal/index.tsx b/examples/client/Locomotion/src/Components/SelectModal/index.tsx index eab0c6bd7..84fe2dea9 100644 --- a/examples/client/Locomotion/src/Components/SelectModal/index.tsx +++ b/examples/client/Locomotion/src/Components/SelectModal/index.tsx @@ -84,12 +84,15 @@ interface Item { interface SelectModalProps { data: Item[]; + defaultValue?: any; onSelect: (item: Item) => void; onError: (error: boolean) => void; } -const SelectModal = ({ data, onSelect, onError }: SelectModalProps) => { - const [selectedItem, setSelectedItem] = useState(null); +const SelectModal = ({ + data, onSelect, onError, defaultValue, +}: SelectModalProps) => { + const [selectedItem, setSelectedItem] = useState(null); const [error, setError] = useState(false); useEffect(() => { @@ -118,6 +121,7 @@ const SelectModal = ({ data, onSelect, onError }: SelectModalProps) => { onSelect={(item, index) => { setSelectedItem(item); }} + defaultValue={defaultValue} dropdownIconPosition="left" dropdownOverlayColor="transparent" buttonTextAfterSelection={(item, index) => item.value} @@ -131,5 +135,8 @@ const SelectModal = ({ data, onSelect, onError }: SelectModalProps) => { /> ); }; +SelectModal.defaultProps = { + defaultValue: null, +}; export default SelectModal; diff --git a/examples/client/Locomotion/src/context/newRideContext/index.tsx b/examples/client/Locomotion/src/context/newRideContext/index.tsx index a1c832631..f859c3157 100644 --- a/examples/client/Locomotion/src/context/newRideContext/index.tsx +++ b/examples/client/Locomotion/src/context/newRideContext/index.tsx @@ -123,7 +123,7 @@ interface RidePageContextInterface { setSpCurrentLocation: () => void; historyResults: any[]; serviceEstimations: any[]; - ride: RideInterface; + ride: RideInterface | null; updateRidePayload: (ride: any) => void; chosenService: any; defaultService: any; @@ -159,7 +159,7 @@ interface RidePageContextInterface { getRidePriceCalculation: (id: string | undefined, priceCalculationId?: string) => Promise; getRideTotalPriceWithCurrency: (rideId : string | undefined) => Promise<{ amount: number; currency: string; } | undefined>; getRidesByParams: (params: any) => Promise; - numberOfPassengers: number, + numberOfPassengers: number | null, setNumberOfPassengers: (num: number) => void, setLastAcknowledgedRideCompletionTimestampToNow: () => void loadFutureBookingDays: () => void; @@ -227,6 +227,8 @@ export const RidePageContext = createContext({ futureBookingDays: 0, businessAccountId: null, updateBusinessAccountId: (newBusinessAccountId: string | null) => undefined, + addNewEmptyRequestSp: () => undefined, + removeRequestSp: (index: number) => undefined, }); const HISTORY_RECORDS_NUM = 10; diff --git a/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/PassengersCounter/index.tsx b/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/PassengersCounter/index.tsx index b66b20840..09f1db928 100644 --- a/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/PassengersCounter/index.tsx +++ b/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/PassengersCounter/index.tsx @@ -4,7 +4,9 @@ import React, { useState, useEffect } from 'react'; import SelectModal from '../../../../../../Components/SelectModal'; -const PassengersCounter = ({ service, onSelect, onError = () => null }) => { +const PassengersCounter = ({ + service, onSelect, onError = () => null, value, +}) => { useEffect(() => { if (service?.availableSeats) { const array = []; @@ -25,6 +27,7 @@ const PassengersCounter = ({ service, onSelect, onError = () => null }) => { data={passengersOptions} onSelect={onItemSelect} onError={onError} + defaultValue={value} /> ); }; diff --git a/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx b/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx index 17e22eea7..b8a7ccec1 100644 --- a/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx +++ b/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx @@ -61,6 +61,7 @@ const RideButtons = ({ futureBookingDays, businessAccountId, serviceEstimations, + numberOfPassengers, } = useContext(RidePageContext); @@ -342,6 +343,7 @@ const RideButtons = ({ service={chosenService} onSelect={setNumberOfPassengers} onError={setPassengersCounterError} + value={numberOfPassengers} /> ) : null} From c0e20cdc82ca9ce60fbd35afbda2010a14a676e0 Mon Sep 17 00:00:00 2001 From: hilat-autofleet Date: Sun, 25 Feb 2024 19:10:37 +0200 Subject: [PATCH 3/4] add temp state --- .../src/Components/SelectModal/index.tsx | 24 +++++++++++-------- .../src/context/newRideContext/index.tsx | 4 ++++ .../RideButtons/PassengersCounter/index.tsx | 19 ++++++++++----- .../RideOptions/RideButtons/index.tsx | 8 ++++--- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/examples/client/Locomotion/src/Components/SelectModal/index.tsx b/examples/client/Locomotion/src/Components/SelectModal/index.tsx index 84fe2dea9..83fa182df 100644 --- a/examples/client/Locomotion/src/Components/SelectModal/index.tsx +++ b/examples/client/Locomotion/src/Components/SelectModal/index.tsx @@ -84,47 +84,51 @@ interface Item { interface SelectModalProps { data: Item[]; - defaultValue?: any; + selectedValue?: any; onSelect: (item: Item) => void; onError: (error: boolean) => void; } const SelectModal = ({ - data, onSelect, onError, defaultValue, + data, onSelect, onError, selectedValue, }: SelectModalProps) => { const [selectedItem, setSelectedItem] = useState(null); const [error, setError] = useState(false); useEffect(() => { if (data?.length) { - if (!selectedItem) { - setSelectedItem(data[0]); + const defaultItem = data.find(i => i.value === selectedValue); + if (defaultItem) { + setSelectedItem(defaultItem); } else { - setError(!(data.find(item => item.value === selectedItem.value))); + setSelectedItem(data[0]); } } - }, [data, selectedItem]); + }, [data.length, selectedValue]); useEffect(() => { onError(error); }, [error]); useEffect(() => { - onSelect(selectedItem); + if (selectedItem) { + onSelect(selectedItem); + setError(!(data.find(item => item.value === selectedItem.value))); + } }, [selectedItem]); return ( { setSelectedItem(item); }} - defaultValue={defaultValue} dropdownIconPosition="left" dropdownOverlayColor="transparent" - buttonTextAfterSelection={(item, index) => item.value} + buttonTextAfterSelection={(item, index) => item.label} renderCustomizedRowChild={(item, index) => ( { + setNumberOfPassengers(-1); + }, [chosenService]); + useEffect(() => { if (user?.id && isAppActive && !ride.id) { loadLastCompletedRide(); diff --git a/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/PassengersCounter/index.tsx b/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/PassengersCounter/index.tsx index 09f1db928..f043a37f6 100644 --- a/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/PassengersCounter/index.tsx +++ b/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/PassengersCounter/index.tsx @@ -3,23 +3,28 @@ import React, { useState, useEffect } from 'react'; import SelectModal from '../../../../../../Components/SelectModal'; +interface Item { + value: number; + label: string; +} const PassengersCounter = ({ - service, onSelect, onError = () => null, value, + service, onSelect, onError = () => null, selectedValue, }) => { + const [passengersOptions, setPassengersOptions] = useState([]); + useEffect(() => { if (service?.availableSeats) { const array = []; for (let i = 1; i <= service.availableSeats; i += 1) { - array.push({ label: i, value: i }); + array.push({ label: i.toString(), value: i }); } setPassengersOptions(array); } }, [service]); - const [passengersOptions, setPassengersOptions] = useState([]); - const onItemSelect = (item) => { + const onItemSelect = (item: Item) => { onSelect(item?.value); }; return ( @@ -27,9 +32,11 @@ const PassengersCounter = ({ data={passengersOptions} onSelect={onItemSelect} onError={onError} - defaultValue={value} + selectedValue={selectedValue} /> ); }; - +PassengersCounter.defaultProps = { + selectedValue: null, +}; export default PassengersCounter; diff --git a/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx b/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx index b8a7ccec1..b9ac2ea0b 100644 --- a/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx +++ b/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx @@ -1,5 +1,5 @@ import React, { - useContext, useState, useEffect, useCallback, + useContext, useState, useEffect, } from 'react'; import DatePicker from 'react-native-date-picker'; import moment from 'moment'; @@ -71,6 +71,7 @@ const RideButtons = ({ const [pickupTimeWindow, setPickupTimeWindow] = useState(0); const [pickupTimeWindowChangedHighlight, setPickupTimeWindowChangedHighlight] = useState(false); const [highEtaPopupVisible, setHighEtaPopupVisible] = useState(false); + const [tempPassengersNumber, setTempPassengersNumber] = useState(0); const { getSettingByKey } = settings.useContainer(); const { paymentMethods, @@ -341,9 +342,9 @@ const RideButtons = ({ ? ( ) : null} @@ -351,6 +352,7 @@ const RideButtons = ({ testID="selectService" disabled={isSelectButtonDisabled()} onPress={() => { + setNumberOfPassengers(tempPassengersNumber); if (chosenService?.isHighEtaAsapRide) { setHighEtaPopupVisible(true); } else { From 1712e47f212d4502721ca9d642884d7c3d3e1b40 Mon Sep 17 00:00:00 2001 From: Sephi Nahmias <24208414+sephina@users.noreply.github.com> Date: Mon, 26 Feb 2024 09:44:11 +0200 Subject: [PATCH 4/4] AUT-18410 default method when only 1 exists https://autofleet.atlassian.net/browse/AUT-18410 --- .../ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx b/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx index 17e22eea7..ddef82176 100644 --- a/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx +++ b/examples/client/Locomotion/src/pages/ActiveRide/RideDrawer/RideOptions/RideButtons/index.tsx @@ -234,7 +234,7 @@ const RideButtons = ({ useEffect(() => { loadOfflinePaymentText(); }, []); - const ridePaymentMethodId = ride?.paymentMethodId || ''; + const ridePaymentMethodId = ride?.paymentMethodId || chosenService?.allowedPaymentMethods?.[0] || ''; const selectedPaymentMethod: PaymentMethodInterface | undefined = paymentMethodIdToDataMap[ridePaymentMethodId] || paymentMethods.find(pm => pm.id === ridePaymentMethodId);