ordering-ui-react-native 0.21.27 → 0.21.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/themes/business/src/components/NewOrderNotification/index.tsx +80 -79
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +9 -7
- package/themes/business/src/components/OrdersOption/index.tsx +83 -1
- package/themes/original/src/components/Checkout/index.tsx +4 -4
- package/themes/original/src/components/OrderDetails/index.tsx +17 -22
- package/themes/original/src/components/OrderProgress/index.tsx +5 -3
- package/themes/original/src/components/ProductForm/index.tsx +1 -1
- package/themes/original/src/utils/index.tsx +113 -0
- package/src/navigators/BottomNavigator.tsx +0 -117
- package/src/navigators/CheckoutNavigator.tsx +0 -66
- package/src/navigators/HomeNavigator.tsx +0 -202
- package/src/navigators/NavigationRef.tsx +0 -7
- package/src/navigators/RootNavigator.tsx +0 -269
- package/src/pages/Account.tsx +0 -34
- package/src/pages/AddressForm.tsx +0 -62
- package/src/pages/AddressList.tsx +0 -24
- package/src/pages/BusinessProductsList.tsx +0 -81
- package/src/pages/BusinessesListing.tsx +0 -43
- package/src/pages/CartList.tsx +0 -49
- package/src/pages/Checkout.tsx +0 -101
- package/src/pages/ForgotPassword.tsx +0 -24
- package/src/pages/Help.tsx +0 -23
- package/src/pages/HelpAccountAndPayment.tsx +0 -23
- package/src/pages/HelpGuide.tsx +0 -23
- package/src/pages/HelpOrder.tsx +0 -23
- package/src/pages/Home.tsx +0 -36
- package/src/pages/IntroductoryTutorial.tsx +0 -170
- package/src/pages/Login.tsx +0 -47
- package/src/pages/MomentOption.tsx +0 -30
- package/src/pages/MultiCheckout.tsx +0 -31
- package/src/pages/MultiOrdersDetails.tsx +0 -27
- package/src/pages/MyOrders.tsx +0 -40
- package/src/pages/NetworkError.tsx +0 -24
- package/src/pages/NotFound.tsx +0 -22
- package/src/pages/OrderDetails.tsx +0 -25
- package/src/pages/ProductDetails.tsx +0 -55
- package/src/pages/Profile.tsx +0 -36
- package/src/pages/ReviewDriver.tsx +0 -30
- package/src/pages/ReviewOrder.tsx +0 -32
- package/src/pages/ReviewProducts.tsx +0 -30
- package/src/pages/Sessions.tsx +0 -22
- package/src/pages/Signup.tsx +0 -53
- package/src/pages/SpinnerLoader.tsx +0 -10
- package/src/pages/Splash.tsx +0 -21
package/package.json
CHANGED
|
@@ -1,22 +1,33 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Modal,
|
|
4
|
+
View,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
Dimensions,
|
|
7
|
+
TouchableOpacity
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import { useTheme } from 'styled-components/native'
|
|
1
10
|
import moment from 'moment'
|
|
2
|
-
import { NewOrderNotification as NewOrderNotificationController, useApi, useEvent, useLanguage, useSession } from 'ordering-components/native'
|
|
3
|
-
import React, { useEffect, useState } from 'react'
|
|
4
|
-
import { Dimensions, Modal, StyleSheet, TouchableOpacity, View } from 'react-native'
|
|
5
|
-
import Sound from 'react-native-sound'
|
|
6
11
|
import Icon from 'react-native-vector-icons/Feather'
|
|
7
|
-
import { useTheme } from 'styled-components/native'
|
|
8
12
|
|
|
9
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
NewOrderNotification as NewOrderNotificationController,
|
|
15
|
+
useApi,
|
|
16
|
+
useEvent,
|
|
17
|
+
useLanguage,
|
|
18
|
+
useSession
|
|
19
|
+
} from 'ordering-components/native'
|
|
20
|
+
|
|
21
|
+
import TrackPlayer from 'react-native-track-player';
|
|
22
|
+
|
|
10
23
|
import { OIcon, OText } from '../shared'
|
|
11
24
|
import { NotificationContainer } from './styles'
|
|
25
|
+
import { useLocation } from '../../hooks/useLocation'
|
|
12
26
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
27
|
+
const SOUND_LOOP_AMOUNT = 3
|
|
28
|
+
const DURATION_BETWEEN_LOOP = 2000 // ms
|
|
16
29
|
const windowWidth = Dimensions.get('screen').width
|
|
17
30
|
|
|
18
|
-
const SOUND_LOOP = 3
|
|
19
|
-
|
|
20
31
|
const NewOrderNotificationUI = (props: any) => {
|
|
21
32
|
const { isBusinessApp } = props
|
|
22
33
|
const [events] = useEvent()
|
|
@@ -24,7 +35,7 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
24
35
|
const [, t] = useLanguage()
|
|
25
36
|
const [{ user, token }] = useSession()
|
|
26
37
|
const [ordering] = useApi()
|
|
27
|
-
const { getCurrentLocation } = useLocation()
|
|
38
|
+
const { getCurrentLocation } = useLocation()
|
|
28
39
|
const [currentEvent, setCurrentEvent] = useState<any>(null)
|
|
29
40
|
|
|
30
41
|
const evtList: any = {
|
|
@@ -45,38 +56,28 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
45
56
|
},
|
|
46
57
|
}
|
|
47
58
|
|
|
48
|
-
const soundSrc = 'https://d33aymufw4jvwf.cloudfront.net/notification.mp3' ?? theme.sounds.notification
|
|
49
|
-
|
|
50
|
-
const notificationSound = new Sound(soundSrc, '', () => { });
|
|
51
|
-
|
|
52
|
-
let _timeout: any = null
|
|
53
|
-
let times = 0
|
|
54
|
-
|
|
55
59
|
const handleCloseEvents = () => {
|
|
56
60
|
setCurrentEvent(null)
|
|
57
|
-
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const playSoundNotification = () => {
|
|
64
|
+
let count = 0;
|
|
65
|
+
const intervalId = setInterval(() => {
|
|
66
|
+
TrackPlayer.seekTo(0)
|
|
67
|
+
TrackPlayer.play()
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
TrackPlayer.pause()
|
|
70
|
+
count++
|
|
71
|
+
if (count === SOUND_LOOP_AMOUNT) {
|
|
72
|
+
clearInterval(intervalId);
|
|
73
|
+
}
|
|
74
|
+
}, 500) // sound duration divide by 2
|
|
75
|
+
}, DURATION_BETWEEN_LOOP) // notification duration
|
|
58
76
|
}
|
|
59
77
|
|
|
60
78
|
const handlePlayNotificationSound = (eventObj: any = null) => {
|
|
61
79
|
setCurrentEvent(eventObj)
|
|
62
|
-
|
|
63
|
-
if (times === 3) {
|
|
64
|
-
times = 0
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
return
|
|
68
|
-
}
|
|
69
|
-
_timeout = setInterval(() => {
|
|
70
|
-
if (times < SOUND_LOOP) {
|
|
71
|
-
notificationSound.play()
|
|
72
|
-
times++
|
|
73
|
-
} else {
|
|
74
|
-
clearInterval(_timeout)
|
|
75
|
-
notificationSound.stop()
|
|
76
|
-
notificationSound.release()
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
}, 2500)
|
|
80
|
+
playSoundNotification()
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
const handleEventNotification = async (evtType: number, value: any) => {
|
|
@@ -98,10 +99,14 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
if (evtType === 3 || value?.author_id === user.id) return
|
|
101
|
-
|
|
102
|
+
handlePlayNotificationSound({
|
|
102
103
|
evt: evtType,
|
|
103
|
-
orderId: value?.driver
|
|
104
|
-
|
|
104
|
+
orderId: value?.driver
|
|
105
|
+
? value?.order_id
|
|
106
|
+
: evtList[evtType].event === 'messages'
|
|
107
|
+
? value?.order?.id
|
|
108
|
+
: value?.order_id ?? value?.id
|
|
109
|
+
})
|
|
105
110
|
}
|
|
106
111
|
|
|
107
112
|
useEffect(() => {
|
|
@@ -123,48 +128,44 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
123
128
|
useEffect(() => {
|
|
124
129
|
return () => {
|
|
125
130
|
handleCloseEvents()
|
|
126
|
-
notificationSound.stop()
|
|
127
|
-
notificationSound.release()
|
|
128
131
|
}
|
|
129
132
|
}, [])
|
|
130
133
|
|
|
131
134
|
return (
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
>
|
|
138
|
-
<
|
|
139
|
-
<
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
</Modal>
|
|
167
|
-
</>
|
|
135
|
+
<Modal
|
|
136
|
+
animationType='slide'
|
|
137
|
+
transparent={true}
|
|
138
|
+
visible={!!currentEvent?.orderId}
|
|
139
|
+
>
|
|
140
|
+
<NotificationContainer>
|
|
141
|
+
<View style={styles.modalView}>
|
|
142
|
+
<TouchableOpacity
|
|
143
|
+
style={styles.wrapperIcon}
|
|
144
|
+
onPress={() => handleCloseEvents()}
|
|
145
|
+
>
|
|
146
|
+
<Icon name="x" size={30} />
|
|
147
|
+
</TouchableOpacity>
|
|
148
|
+
<OText
|
|
149
|
+
size={18}
|
|
150
|
+
color={theme.colors.textGray}
|
|
151
|
+
weight={600}
|
|
152
|
+
>
|
|
153
|
+
{evtList[currentEvent?.evt]?.message}
|
|
154
|
+
</OText>
|
|
155
|
+
<OIcon
|
|
156
|
+
src={theme.images.general.newOrder}
|
|
157
|
+
width={250}
|
|
158
|
+
height={200}
|
|
159
|
+
/>
|
|
160
|
+
<OText
|
|
161
|
+
color={theme.colors.textGray}
|
|
162
|
+
mBottom={15}
|
|
163
|
+
>
|
|
164
|
+
{evtList[currentEvent?.evt]?.message2}
|
|
165
|
+
</OText>
|
|
166
|
+
</View>
|
|
167
|
+
</NotificationContainer>
|
|
168
|
+
</Modal>
|
|
168
169
|
)
|
|
169
170
|
}
|
|
170
171
|
|
|
@@ -275,12 +275,12 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
|
|
|
275
275
|
{t(order?.delivery_option?.name?.toUpperCase()?.replace(/ /g, '_'), order?.delivery_option?.name)}
|
|
276
276
|
</OText>
|
|
277
277
|
)}
|
|
278
|
-
|
|
279
|
-
<
|
|
278
|
+
<OText>
|
|
279
|
+
<OText size={13} weight='bold'>
|
|
280
|
+
{`${t('PAYMENT_METHODS', 'Payment methods')}: `}
|
|
281
|
+
</OText>
|
|
282
|
+
{order?.payment_events?.length > 0 ? (
|
|
280
283
|
<OText size={13}>
|
|
281
|
-
<OText size={13} weight='bold'>
|
|
282
|
-
{`${t('PAYMENT_METHODS', 'Payment methods')}: `}
|
|
283
|
-
</OText>
|
|
284
284
|
{order?.payment_events?.map((event: any, idx: number) => {
|
|
285
285
|
return event?.wallet_event
|
|
286
286
|
? idx < order?.payment_events?.length - 1
|
|
@@ -291,8 +291,10 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
|
|
|
291
291
|
: t(event?.paymethod?.name?.toUpperCase()?.replace(/ /g, '_'), event?.paymethod?.name)
|
|
292
292
|
})}
|
|
293
293
|
</OText>
|
|
294
|
-
|
|
295
|
-
|
|
294
|
+
) : (
|
|
295
|
+
<OText size={13}>{t(order?.paymethod?.gateway?.toUpperCase(), order?.paymethod?.name)}</OText>
|
|
296
|
+
)}
|
|
297
|
+
</OText>
|
|
296
298
|
</>
|
|
297
299
|
)}
|
|
298
300
|
</OrderHeader>
|
|
@@ -6,6 +6,12 @@ import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
|
6
6
|
import FeatherIcon from 'react-native-vector-icons/Feather';
|
|
7
7
|
import FontistoIcon from 'react-native-vector-icons/Fontisto'
|
|
8
8
|
import AntDesignIcon from 'react-native-vector-icons/AntDesign'
|
|
9
|
+
import TrackPlayer, {
|
|
10
|
+
RepeatMode,
|
|
11
|
+
Capability,
|
|
12
|
+
AppKilledPlaybackBehavior
|
|
13
|
+
} from 'react-native-track-player';
|
|
14
|
+
|
|
9
15
|
import { useTheme } from 'styled-components/native';
|
|
10
16
|
import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
|
|
11
17
|
import { NotificationSetting } from '../../../../../src/components/NotificationSetting'
|
|
@@ -106,6 +112,79 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
106
112
|
const HEIGHT_SCREEN = orientationState?.dimensions?.height
|
|
107
113
|
const IS_PORTRAIT = orientationState.orientation === PORTRAIT
|
|
108
114
|
|
|
115
|
+
const URL_SOUND = 'https://d33aymufw4jvwf.cloudfront.net/notification.mp3' ?? theme.sounds.notification
|
|
116
|
+
|
|
117
|
+
const setupPlayer = async (options: any) => {
|
|
118
|
+
const setup = async () => {
|
|
119
|
+
try {
|
|
120
|
+
await TrackPlayer.setupPlayer(options);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
return (error as Error & { code?: string }).code;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
while ((await setup()) === 'android_cannot_setup_player_in_background') {
|
|
126
|
+
await new Promise<void>((resolve) => setTimeout(resolve, 1));
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const SetupService = async () => {
|
|
131
|
+
await setupPlayer({ autoHandleInterruptions: true });
|
|
132
|
+
await TrackPlayer.updateOptions({
|
|
133
|
+
android: {
|
|
134
|
+
appKilledPlaybackBehavior:
|
|
135
|
+
AppKilledPlaybackBehavior.StopPlaybackAndRemoveNotification,
|
|
136
|
+
},
|
|
137
|
+
capabilities: [
|
|
138
|
+
Capability.Play,
|
|
139
|
+
Capability.Pause,
|
|
140
|
+
Capability.SkipToNext,
|
|
141
|
+
Capability.SkipToPrevious,
|
|
142
|
+
Capability.SeekTo,
|
|
143
|
+
],
|
|
144
|
+
compactCapabilities: [
|
|
145
|
+
Capability.Play,
|
|
146
|
+
Capability.Pause,
|
|
147
|
+
Capability.SkipToNext,
|
|
148
|
+
],
|
|
149
|
+
progressUpdateEventInterval: 2,
|
|
150
|
+
});
|
|
151
|
+
await TrackPlayer.setRepeatMode(RepeatMode.Track);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const QueueInitialTracksService = async () => {
|
|
155
|
+
await TrackPlayer.add([
|
|
156
|
+
{
|
|
157
|
+
id: 'notification',
|
|
158
|
+
url: URL_SOUND,
|
|
159
|
+
title: 'notification'
|
|
160
|
+
},
|
|
161
|
+
]);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function useSetupPlayer() {
|
|
165
|
+
const [playerReady, setPlayerReady] = useState<boolean>(false)
|
|
166
|
+
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
let unmounted = false;
|
|
169
|
+
(async () => {
|
|
170
|
+
await SetupService()
|
|
171
|
+
if (unmounted) return
|
|
172
|
+
setPlayerReady(true)
|
|
173
|
+
const queue = await TrackPlayer.getQueue()
|
|
174
|
+
if (unmounted) return
|
|
175
|
+
if (queue.length <= 0) {
|
|
176
|
+
await QueueInitialTracksService()
|
|
177
|
+
}
|
|
178
|
+
})();
|
|
179
|
+
return () => {
|
|
180
|
+
unmounted = true;
|
|
181
|
+
};
|
|
182
|
+
}, []);
|
|
183
|
+
return playerReady;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const isPlayerReady = useSetupPlayer()
|
|
187
|
+
|
|
109
188
|
const preorderTypeList = [
|
|
110
189
|
{ key: null, name: t('SLA', 'SLA\'s') },
|
|
111
190
|
{ key: 'in_time', name: t('OK', 'Ok') },
|
|
@@ -701,7 +780,10 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
701
780
|
</View>
|
|
702
781
|
|
|
703
782
|
{isBusinessApp && (
|
|
704
|
-
<NewOrderNotification
|
|
783
|
+
<NewOrderNotification
|
|
784
|
+
isBusinessApp={isBusinessApp}
|
|
785
|
+
isPlayerReady={isPlayerReady}
|
|
786
|
+
/>
|
|
705
787
|
)}
|
|
706
788
|
|
|
707
789
|
{(openSearchModal || openSLASettingModal) && (
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useState, useEffect, useCallback } from 'react';
|
|
2
2
|
import { View, StyleSheet, TouchableOpacity, Platform, I18nManager, ScrollView } from 'react-native';
|
|
3
3
|
import { initStripe, useConfirmPayment } from '@stripe/stripe-react-native';
|
|
4
|
+
import NativeStripeSdk from '@stripe/stripe-react-native/src/NativeStripeSdk'
|
|
4
5
|
import Picker from 'react-native-country-picker-modal';
|
|
5
6
|
import MaterialIcons from 'react-native-vector-icons/MaterialIcons'
|
|
6
7
|
import ReactNativeHapticFeedback from "react-native-haptic-feedback";
|
|
@@ -48,7 +49,6 @@ import {
|
|
|
48
49
|
CartHeader
|
|
49
50
|
} from './styles';
|
|
50
51
|
import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
|
|
51
|
-
|
|
52
52
|
import { FloatingButton } from '../FloatingButton';
|
|
53
53
|
import { Container } from '../../layouts/Container';
|
|
54
54
|
import NavBar from '../NavBar';
|
|
@@ -164,7 +164,7 @@ const CheckoutUI = (props: any) => {
|
|
|
164
164
|
const [methodPaySupported, setMethodPaySupported] = useState({ enabled: false, message: null, loading: true })
|
|
165
165
|
const [cardList, setCardList] = useState<any>({ cards: [], loading: false, error: null })
|
|
166
166
|
const cardsMethods = ['credomatic']
|
|
167
|
-
|
|
167
|
+
const stripePaymethods: any = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect']
|
|
168
168
|
const placeSpotTypes = [3, 4, 5]
|
|
169
169
|
const placeSpotsEnabled = placeSpotTypes.includes(options?.type)
|
|
170
170
|
const isGiftCardCart = !cart?.business_id
|
|
@@ -239,7 +239,7 @@ const CheckoutUI = (props: any) => {
|
|
|
239
239
|
token: user?.session?.access_token
|
|
240
240
|
})
|
|
241
241
|
openModal?.isGuest && handlePlaceOrderAsGuest()
|
|
242
|
-
|
|
242
|
+
setOpenModal({ ...openModal, signup: false, isGuest: false })
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
const handleSuccessLogin = (user: any) => {
|
|
@@ -254,7 +254,7 @@ const CheckoutUI = (props: any) => {
|
|
|
254
254
|
|
|
255
255
|
if (!userErrors.length && (!requiredFields?.length || allowedGuest) || forcePlace) {
|
|
256
256
|
vibrateApp()
|
|
257
|
-
handlerClickPlaceOrder && handlerClickPlaceOrder(null, { isNative: true }, confirmPayment)
|
|
257
|
+
handlerClickPlaceOrder && handlerClickPlaceOrder(null, { isNative: true }, confirmPayment, NativeStripeSdk?.dismissPlatformPay)
|
|
258
258
|
return
|
|
259
259
|
}
|
|
260
260
|
if (requiredFields?.length) {
|
|
@@ -42,7 +42,7 @@ import { ProductItemAccordion } from '../ProductItemAccordion';
|
|
|
42
42
|
import { TouchableOpacity } from 'react-native-gesture-handler';
|
|
43
43
|
import { OrderDetailsParams } from '../../types';
|
|
44
44
|
import { GoogleMap } from '../GoogleMap';
|
|
45
|
-
import { verifyDecimals, getOrderStatus } from '../../utils';
|
|
45
|
+
import { verifyDecimals, getOrderStatus, getOrderStatuPickUp } from '../../utils';
|
|
46
46
|
import { OSRow } from '../OrderSummary/styles';
|
|
47
47
|
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
48
48
|
import { TaxInformation } from '../TaxInformation';
|
|
@@ -124,6 +124,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
124
124
|
const placeSpotTypes = [3, 4, 5]
|
|
125
125
|
const directionTypes = [2, 3, 4, 5]
|
|
126
126
|
const activeStatus = [0, 3, 4, 7, 8, 9, 13, 14, 18, 19, 20, 21, 22, 23]
|
|
127
|
+
const reorderStatus = [1, 2, 5, 6, 10, 11, 12]
|
|
127
128
|
const enabledPoweredByOrdering = configs?.powered_by_ordering_module?.value
|
|
128
129
|
const isGiftCardOrder = !order?.business_id
|
|
129
130
|
const hideDeliveryDate = theme?.confirmation?.components?.order?.components?.date?.hidden
|
|
@@ -345,6 +346,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
345
346
|
}
|
|
346
347
|
}, [props?.order?.error, props?.order?.loading])
|
|
347
348
|
|
|
349
|
+
const progressBarObjt = order?.delivery_type && props.order?.delivery_type === 2 ? getOrderStatuPickUp : getOrderStatus
|
|
350
|
+
|
|
348
351
|
return (
|
|
349
352
|
<OrderDetailsContainer
|
|
350
353
|
keyboardShouldPersistTaps="handled"
|
|
@@ -480,7 +483,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
480
483
|
<LinearGradient
|
|
481
484
|
start={{ x: 0.0, y: 0.0 }}
|
|
482
485
|
end={{
|
|
483
|
-
x:
|
|
486
|
+
x: progressBarObjt(order?.status)?.percentage || 0,
|
|
484
487
|
y: 0,
|
|
485
488
|
}}
|
|
486
489
|
locations={[0.9999, 0.9999]}
|
|
@@ -493,7 +496,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
493
496
|
lineHeight={24}
|
|
494
497
|
weight={'600'}
|
|
495
498
|
color={theme.colors.textNormal}>
|
|
496
|
-
{
|
|
499
|
+
{progressBarObjt(order?.status)?.value}
|
|
497
500
|
</OText>
|
|
498
501
|
</>
|
|
499
502
|
)}
|
|
@@ -791,25 +794,17 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
791
794
|
parentStyle={{ marginTop: 29, marginEnd: 15 }}
|
|
792
795
|
onClick={() => navigation.navigate('BottomTab', { screen: 'MyOrders' })}
|
|
793
796
|
/>
|
|
794
|
-
{(
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
textStyle={{ fontSize: 14, color: theme.colors.primary }}
|
|
806
|
-
imgRightSrc={null}
|
|
807
|
-
borderColor='transparent'
|
|
808
|
-
bgColor={theme.colors.primary + 10}
|
|
809
|
-
style={{ borderRadius: 7.6, borderWidth: 1, height: 44, shadowOpacity: 0, marginTop: 29 }}
|
|
810
|
-
onClick={() => handleReorder && handleReorder(order.id)}
|
|
811
|
-
/>
|
|
812
|
-
)}
|
|
797
|
+
{(reorderStatus?.includes(parseInt(order?.status)) && order?.cart) && (
|
|
798
|
+
<OButton
|
|
799
|
+
text={order.id === reorderState?.loading ? t('LOADING', 'Loading..') : t('REORDER', 'Reorder')}
|
|
800
|
+
textStyle={{ fontSize: 14, color: theme.colors.primary }}
|
|
801
|
+
imgRightSrc={null}
|
|
802
|
+
borderColor='transparent'
|
|
803
|
+
bgColor={theme.colors.primary + 10}
|
|
804
|
+
style={{ borderRadius: 7.6, borderWidth: 1, height: 44, shadowOpacity: 0, marginTop: 29 }}
|
|
805
|
+
onClick={() => handleReorder && handleReorder(order.id)}
|
|
806
|
+
/>
|
|
807
|
+
)}
|
|
813
808
|
</OrderAction>
|
|
814
809
|
</HeaderInfo>
|
|
815
810
|
<OrderProducts>
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
OrderInfoWrapper,
|
|
23
23
|
OrderProgressWrapper
|
|
24
24
|
} from './styles'
|
|
25
|
-
import { getOrderStatus } from '../../utils'
|
|
25
|
+
import { getOrderStatuPickUp, getOrderStatus } from '../../utils'
|
|
26
26
|
|
|
27
27
|
const OrderProgressUI = (props: any) => {
|
|
28
28
|
const {
|
|
@@ -110,6 +110,8 @@ const OrderProgressUI = (props: any) => {
|
|
|
110
110
|
setInitialLoaded(true)
|
|
111
111
|
}, [orderList.loading, initialLoaded])
|
|
112
112
|
|
|
113
|
+
const progressBarObjt = lastOrder?.delivery_type && lastOrder?.delivery_type === 2 ? getOrderStatuPickUp : getOrderStatus
|
|
114
|
+
|
|
113
115
|
return (
|
|
114
116
|
<>
|
|
115
117
|
{(orderList?.loading && !initialLoaded) && (
|
|
@@ -162,10 +164,10 @@ const OrderProgressUI = (props: any) => {
|
|
|
162
164
|
</OrderInfoWrapper>
|
|
163
165
|
<View style={{ flex: 1 }}>
|
|
164
166
|
<ProgressContentWrapper>
|
|
165
|
-
<ProgressBar style={{ width:
|
|
167
|
+
<ProgressBar style={{ width: progressBarObjt(lastOrder.status)?.percentage ? `${(progressBarObjt(lastOrder.status) as any).percentage * 100}%` : '0%' }} />
|
|
166
168
|
</ProgressContentWrapper>
|
|
167
169
|
<ProgressTextWrapper>
|
|
168
|
-
<OText size={12} style={{ width: '50%' }}>{
|
|
170
|
+
<OText size={12} style={{ width: '50%' }}>{progressBarObjt(lastOrder.status)?.value}</OText>
|
|
169
171
|
<TimeWrapper>
|
|
170
172
|
<OText size={11}>{lastOrder?.delivery_type === 1 ? t('ESTIMATED_DELIVERY', 'Estimated delivery') : t('ESTIMATED_TIME', 'Estimated time')}</OText>
|
|
171
173
|
<OText size={11}>
|
|
@@ -575,6 +575,119 @@ export const getOrderStatus = (s: string) => {
|
|
|
575
575
|
return objectStatus && objectStatus;
|
|
576
576
|
}
|
|
577
577
|
|
|
578
|
+
export const getOrderStatuPickUp = (s: any) => {
|
|
579
|
+
const status = parseInt(s);
|
|
580
|
+
const orderStatus = [
|
|
581
|
+
{
|
|
582
|
+
key: 0,
|
|
583
|
+
value: t('PENDING', 'Pending'),
|
|
584
|
+
slug: 'PENDING',
|
|
585
|
+
percentage: 0.1,
|
|
586
|
+
image: theme.images.order.status0,
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
key: 1,
|
|
590
|
+
value: t('COMPLETED', 'Completed'),
|
|
591
|
+
slug: 'COMPLETED',
|
|
592
|
+
percentage: 1,
|
|
593
|
+
image: theme.images.order.status1,
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
key: 2,
|
|
597
|
+
value: t('REJECTED', 'Rejected'),
|
|
598
|
+
slug: 'REJECTED',
|
|
599
|
+
percentage: 0,
|
|
600
|
+
image: theme.images.order.status2,
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
key: 4,
|
|
604
|
+
value: t('PREPARATION_COMPLETED', 'Preparation Completed'),
|
|
605
|
+
slug: 'PREPARATION_COMPLETED',
|
|
606
|
+
percentage: 0.5,
|
|
607
|
+
image: theme.images.order.status4,
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
key: 5,
|
|
611
|
+
value: t('REJECTED_BY_BUSINESS', 'Rejected by business'),
|
|
612
|
+
slug: 'REJECTED_BY_BUSINESS',
|
|
613
|
+
percentage: 0,
|
|
614
|
+
image: theme.images.order.status5,
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
key: 7,
|
|
618
|
+
value: t('ACCEPTED_BY_BUSINESS', 'Accepted by business'),
|
|
619
|
+
slug: 'ACCEPTED_BY_BUSINESS',
|
|
620
|
+
percentage: 0.3,
|
|
621
|
+
image: theme.images.order.status7,
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
key: 13,
|
|
625
|
+
value: t('PREORDER', 'PreOrder'),
|
|
626
|
+
slug: 'PREORDER',
|
|
627
|
+
percentage: 0,
|
|
628
|
+
image: theme.images.order.status13,
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
key: 14,
|
|
632
|
+
value: t('ORDER_NOT_READY', 'Order not ready'),
|
|
633
|
+
slug: 'ORDER_NOT_READY',
|
|
634
|
+
percentage: 0.3,
|
|
635
|
+
image: theme.images.order.status13,
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
key: 15,
|
|
639
|
+
value: t(
|
|
640
|
+
'ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER',
|
|
641
|
+
'Order picked up completed by customer',
|
|
642
|
+
),
|
|
643
|
+
slug: 'ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER',
|
|
644
|
+
percentage: 1,
|
|
645
|
+
image: theme.images.order.status1,
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
key: 16,
|
|
649
|
+
value: t('CANCELLED_BY_CUSTOMER', 'Cancelled by customer'),
|
|
650
|
+
slug: 'CANCELLED_BY_CUSTOMER',
|
|
651
|
+
percentage: 0,
|
|
652
|
+
image: theme.images.order.status2,
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
key: 17,
|
|
656
|
+
value: t(
|
|
657
|
+
'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
|
|
658
|
+
'Order not picked up by customer',
|
|
659
|
+
),
|
|
660
|
+
slug: 'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
|
|
661
|
+
percentage: 0,
|
|
662
|
+
image: theme.images.order.status2,
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
key: 20,
|
|
666
|
+
value: t(
|
|
667
|
+
'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
|
|
668
|
+
'Customer almost arrived to business',
|
|
669
|
+
),
|
|
670
|
+
slug: 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
|
|
671
|
+
percentage: 0.7,
|
|
672
|
+
image: theme.images.order.status7,
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
key: 21,
|
|
676
|
+
value: t(
|
|
677
|
+
'ORDER_CUSTOMER_ARRIVED_BUSINESS',
|
|
678
|
+
'Customer arrived to business',
|
|
679
|
+
),
|
|
680
|
+
slug: 'ORDER_CUSTOMER_ARRIVED_BUSINESS',
|
|
681
|
+
percentage: 0.9,
|
|
682
|
+
image: theme.images.order.status7,
|
|
683
|
+
}
|
|
684
|
+
];
|
|
685
|
+
|
|
686
|
+
const objectStatus = orderStatus.find((o) => o.key === status);
|
|
687
|
+
|
|
688
|
+
return objectStatus && objectStatus;
|
|
689
|
+
}
|
|
690
|
+
|
|
578
691
|
/**
|
|
579
692
|
* Function to get brightness of color.
|
|
580
693
|
*/
|