ordering-ui-react-native 0.15.14 → 0.15.15-release
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 +5 -3
- package/src/DeliveryApp.tsx +43 -1
- package/src/components/BusinessTypeFilter/index.tsx +12 -2
- package/src/components/BusinessTypeFilter/styles.tsx +1 -1
- package/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/Checkout/index.tsx +0 -1
- package/src/components/LanguageSelector/index.tsx +1 -0
- package/src/components/OrderDetails/index.tsx +26 -5
- package/src/components/PaymentOptions/index.tsx +9 -16
- package/src/components/PaymentOptionsWebView/index.tsx +123 -124
- package/src/components/ProductForm/index.tsx +1 -1
- package/src/components/ProductForm/styles.tsx +1 -0
- package/src/components/StripeElementsForm/index.tsx +27 -48
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/config.json +0 -2
- package/src/navigators/HomeNavigator.tsx +6 -0
- package/src/pages/BusinessProductsList.tsx +1 -0
- package/src/pages/BusinessesListing.tsx +1 -1
- package/src/pages/Checkout.tsx +1 -1
- package/src/pages/Sessions.tsx +22 -0
- package/src/types/index.tsx +1 -9
- package/src/utils/index.tsx +68 -1
- package/themes/business/index.tsx +2 -0
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +56 -8
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +5 -0
- package/themes/business/src/components/Home/index.tsx +128 -55
- package/themes/business/src/components/Home/styles.tsx +8 -1
- package/themes/business/src/components/NewOrderNotification/index.tsx +59 -98
- package/themes/business/src/components/OrderDetails/Business.tsx +2 -1
- package/themes/business/src/components/OrderDetails/Delivery.tsx +19 -12
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +150 -89
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +91 -17
- package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
- package/themes/business/src/components/OrdersListManager/index.tsx +874 -0
- package/themes/business/src/components/OrdersListManager/styles.tsx +123 -0
- package/themes/business/src/components/OrdersListManager/utils.tsx +216 -0
- package/themes/business/src/components/OrdersOption/index.tsx +70 -116
- package/themes/business/src/components/OrdersOption/styles.tsx +2 -5
- package/themes/business/src/components/PreviousOrders/index.tsx +82 -23
- package/themes/business/src/types/index.tsx +2 -1
- package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
- package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
- package/themes/kiosk/src/components/BusinessController/index.tsx +27 -6
- package/themes/kiosk/src/components/BusinessController/styles.tsx +1 -1
- package/themes/kiosk/src/components/BusinessProductsListing/index.tsx +48 -21
- package/themes/kiosk/src/components/Cart/index.tsx +98 -24
- package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
- package/themes/kiosk/src/components/CartBottomSheet/index.tsx +1 -1
- package/themes/kiosk/src/components/CartBottomSheet/styles.tsx +1 -1
- package/themes/kiosk/src/components/CartContent/index.tsx +13 -3
- package/themes/kiosk/src/components/CartItem/index.tsx +20 -8
- package/themes/kiosk/src/components/CategoriesMenu/index.tsx +6 -5
- package/themes/kiosk/src/components/CustomerName/index.tsx +89 -88
- package/themes/kiosk/src/components/Intro/index.tsx +13 -13
- package/themes/kiosk/src/components/LanguageSelector/index.tsx +12 -8
- package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
- package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderDetails/index.tsx +136 -41
- package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
- package/themes/kiosk/src/components/OrderSummary/index.tsx +1 -1
- package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
- package/themes/kiosk/src/components/ProductForm/index.tsx +174 -125
- package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
- package/themes/kiosk/src/components/ProductOption/index.tsx +1 -0
- package/themes/kiosk/src/components/ProductOption/styles.tsx +1 -0
- package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
- package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
- package/themes/kiosk/src/components/shared/OCard.tsx +112 -78
- package/themes/kiosk/src/types/index.d.ts +2 -0
- package/themes/original/index.tsx +179 -0
- package/themes/original/src/components/AddressForm/index.tsx +15 -10
- package/themes/original/src/components/AddressList/index.tsx +56 -18
- package/themes/original/src/components/AppleLogin/index.tsx +117 -78
- package/themes/original/src/components/BusinessBasicInformation/index.tsx +96 -45
- package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
- package/themes/original/src/components/BusinessController/index.tsx +52 -22
- package/themes/original/src/components/BusinessController/styles.tsx +22 -0
- package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
- package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
- package/themes/original/src/components/BusinessListingSearch/index.tsx +4 -0
- package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
- package/themes/original/src/components/BusinessPreorder/index.tsx +141 -121
- package/themes/original/src/components/BusinessProductsCategories/index.tsx +7 -5
- package/themes/original/src/components/BusinessProductsList/index.tsx +129 -22
- package/themes/original/src/components/BusinessProductsList/styles.tsx +29 -2
- package/themes/original/src/components/BusinessProductsListing/index.tsx +92 -37
- package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
- package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
- package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
- package/themes/original/src/components/BusinessesListing/index.tsx +49 -58
- package/themes/original/src/components/Cart/index.tsx +58 -21
- package/themes/original/src/components/CartContent/index.tsx +2 -2
- package/themes/original/src/components/Checkout/index.tsx +24 -28
- package/themes/original/src/components/CouponControl/index.tsx +1 -0
- package/themes/original/src/components/DriverTips/index.tsx +1 -1
- package/themes/original/src/components/HighestRatedBusinesses/index.tsx +97 -89
- package/themes/original/src/components/Home/index.tsx +1 -1
- package/themes/original/src/components/LoginForm/index.tsx +73 -2
- package/themes/original/src/components/LoginForm/styles.tsx +6 -1
- package/themes/original/src/components/MessageListing/index.tsx +10 -1
- package/themes/original/src/components/Messages/index.tsx +50 -45
- package/themes/original/src/components/Messages/styles.tsx +1 -3
- package/themes/original/src/components/MomentOption/index.tsx +10 -1
- package/themes/original/src/components/MomentOption/styles.tsx +1 -1
- package/themes/original/src/components/OrderDetails/index.tsx +105 -127
- package/themes/original/src/components/OrderDetails/styles.tsx +3 -1
- package/themes/original/src/components/OrderProgress/index.tsx +4 -4
- package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
- package/themes/original/src/components/OrderSummary/index.tsx +35 -2
- package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
- package/themes/original/src/components/OrdersOption/index.tsx +25 -33
- package/themes/original/src/components/OrdersOption/styles.tsx +0 -6
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +9 -4
- package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
- package/themes/original/src/components/PaymentOptions/index.tsx +9 -19
- package/themes/original/src/components/PlaceSpot/index.tsx +114 -0
- package/themes/original/src/components/PlaceSpot/styles.tsx +11 -0
- package/themes/original/src/components/PreviousOrders/index.tsx +19 -13
- package/themes/original/src/components/ProductForm/index.tsx +47 -36
- package/themes/original/src/components/ProductForm/styles.tsx +2 -2
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +5 -3
- package/themes/original/src/components/Promotions/index.tsx +234 -0
- package/themes/original/src/components/Promotions/styles.tsx +60 -0
- package/themes/original/src/components/ReviewOrder/index.tsx +10 -9
- package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
- package/themes/original/src/components/Sessions/index.tsx +160 -0
- package/themes/original/src/components/Sessions/styles.tsx +15 -0
- package/themes/original/src/components/SingleProductCard/index.tsx +47 -21
- package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
- package/themes/original/src/components/StripeElementsForm/index.tsx +55 -72
- package/themes/original/src/components/TaxInformation/index.tsx +17 -7
- package/themes/original/src/components/UpsellingProducts/index.tsx +87 -71
- package/themes/original/src/components/UserDetails/index.tsx +4 -95
- package/themes/original/src/components/UserFormDetails/index.tsx +32 -31
- package/themes/original/src/components/UserProfile/index.tsx +70 -20
- package/themes/original/src/components/UserProfileForm/index.tsx +28 -24
- package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
- package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
- package/themes/original/src/components/Wallets/index.tsx +75 -8
- package/themes/original/src/components/Wallets/styles.tsx +21 -0
- package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
- package/themes/original/src/components/shared/index.tsx +2 -0
- package/themes/original/src/config/constants.tsx +6 -6
- package/themes/original/src/types/index.tsx +78 -25
- package/themes/original/src/utils/index.tsx +12 -2
- package/themes/single-business/src/components/AddressList/index.tsx +1 -1
- package/themes/single-business/src/components/OrderTypeSelector/index.tsx +6 -6
- package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
- package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
- package/src/components/StripeMethodForm/index.tsx +0 -168
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import styled from 'styled-components/native';
|
|
1
|
+
import styled, { css } from 'styled-components/native';
|
|
2
2
|
|
|
3
3
|
export const Container = styled.View`
|
|
4
4
|
width: 100%;
|
|
@@ -25,3 +25,10 @@ export const BackgroundImage = styled.ImageBackground`
|
|
|
25
25
|
align-items: center;
|
|
26
26
|
padding: 20px 40px;
|
|
27
27
|
`;
|
|
28
|
+
|
|
29
|
+
export const FormInput = styled.View`
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
width: 100%;
|
|
33
|
+
min-height: 50px;
|
|
34
|
+
`;
|
|
@@ -1,50 +1,55 @@
|
|
|
1
|
-
import React, { useState, useEffect
|
|
2
|
-
import
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import moment from 'moment'
|
|
3
3
|
import { View, Modal, StyleSheet, TouchableOpacity, Dimensions } from 'react-native'
|
|
4
|
-
import
|
|
5
|
-
import { useTheme } from 'styled-components/native'
|
|
4
|
+
import Sound from 'react-native-sound'
|
|
6
5
|
import Icon from 'react-native-vector-icons/Feather'
|
|
6
|
+
import { useTheme } from 'styled-components/native'
|
|
7
|
+
import { useEvent, useLanguage, useSession, useApi, NewOrderNotification as NewOrderNotificationController } from 'ordering-components/native'
|
|
8
|
+
|
|
9
|
+
import { OText, OIcon } from '../shared'
|
|
7
10
|
import { NotificationContainer } from './styles'
|
|
8
|
-
import Sound from 'react-native-sound'
|
|
9
|
-
import moment from 'moment'
|
|
10
11
|
import { useLocation } from '../../hooks/useLocation'
|
|
11
|
-
|
|
12
|
+
|
|
12
13
|
Sound.setCategory('Playback')
|
|
13
14
|
|
|
14
15
|
const windowWidth = Dimensions.get('screen').width
|
|
15
16
|
|
|
16
|
-
const NewOrderNotificationUI = (
|
|
17
|
+
const NewOrderNotificationUI = () => {
|
|
17
18
|
const [events] = useEvent()
|
|
18
19
|
const theme = useTheme()
|
|
19
20
|
const [, t] = useLanguage()
|
|
20
21
|
const [{ user, token }] = useSession()
|
|
21
22
|
const [ordering] = useApi()
|
|
22
|
-
const [{ getTimeAgo }] = useUtils()
|
|
23
23
|
const { getCurrentLocation } = useLocation();
|
|
24
|
-
const [modalOpen, setModalOpen] = useState(false)
|
|
25
|
-
const [newOrderId, setNewOrderId] = useState(null)
|
|
26
|
-
const [messageOrderId, setMessageOrderId] = useState(null)
|
|
27
24
|
const [soundTimeout, setSoundTimeout] = useState<any>(null)
|
|
28
|
-
const [
|
|
29
|
-
|
|
25
|
+
const [currentEvent, setCurrentEvent] = useState<any>(null)
|
|
26
|
+
|
|
27
|
+
const evtList: any = {
|
|
28
|
+
1: {
|
|
29
|
+
event: 'messages',
|
|
30
|
+
message: t('NEW_MESSAGES_RECEIVED', 'New messages have been received!'),
|
|
31
|
+
message2: t('ORDER_N_UNREAD_MESSAGES', 'Order #_order_id_ has unread messages.').replace('_order_id_', currentEvent?.orderId),
|
|
32
|
+
},
|
|
33
|
+
2: {
|
|
34
|
+
event: 'order_added',
|
|
35
|
+
message: t('NEW_ORDERS_RECEIVED', 'New orders have been received!'),
|
|
36
|
+
message2: t('ORDER_N_ORDERED', 'Order #_order_id_ has been ordered.').replace('_order_id_', currentEvent?.orderId),
|
|
37
|
+
},
|
|
38
|
+
3: {
|
|
39
|
+
event: 'order_updated',
|
|
40
|
+
message: t('NEW_ORDERS_UPDATED', 'New orders have been updated!'),
|
|
41
|
+
message2: t('ORDER_N_UPDATED', 'Order #_order_id_ has been updated.').replace('_order_id_', currentEvent?.orderId),
|
|
42
|
+
},
|
|
43
|
+
}
|
|
30
44
|
|
|
31
|
-
const notificationSound = new Sound(theme.sounds.notification,
|
|
32
|
-
if (error) {
|
|
33
|
-
console.log('failed to load the sound', error);
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
console.log('loaded successfully');
|
|
37
|
-
});
|
|
45
|
+
const notificationSound = new Sound(theme.sounds.notification, (e) => { console.log(e) });
|
|
38
46
|
|
|
39
47
|
const handlePlayNotificationSound = () => {
|
|
40
48
|
let times = 0
|
|
41
49
|
const _timeout = setInterval(function () {
|
|
42
50
|
notificationSound.play(success => {
|
|
43
51
|
if (success) {
|
|
44
|
-
console.log('successfully finished playing');
|
|
45
52
|
times = times + 1
|
|
46
|
-
} else {
|
|
47
|
-
console.log('playback failed due to audio decoding errors');
|
|
48
53
|
}
|
|
49
54
|
})
|
|
50
55
|
setSoundTimeout(_timeout)
|
|
@@ -57,39 +62,11 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
57
62
|
|
|
58
63
|
const handleCloseModal = () => {
|
|
59
64
|
clearInterval(soundTimeout)
|
|
60
|
-
|
|
61
|
-
setNewOrderId(null)
|
|
62
|
-
setMessageOrderId(null)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const handleNotification = (order: any) => {
|
|
66
|
-
setModalOpen(true)
|
|
67
|
-
clearInterval(soundTimeout)
|
|
68
|
-
setCurrentChange(1)
|
|
69
|
-
handlePlayNotificationSound()
|
|
70
|
-
setNewOrderId(order.id)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const handleMessageNotification = (message: any) => {
|
|
74
|
-
const { order_id: orderId } = message;
|
|
75
|
-
if (!modalOpen) setModalOpen(true)
|
|
76
|
-
clearInterval(soundTimeout)
|
|
77
|
-
setCurrentChange(2)
|
|
78
|
-
handlePlayNotificationSound()
|
|
79
|
-
setMessageOrderId(orderId)
|
|
65
|
+
setCurrentEvent({ evt: null })
|
|
80
66
|
}
|
|
81
67
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
events.on('message_added_noification', handleMessageNotification)
|
|
85
|
-
return () => {
|
|
86
|
-
events.off('order_added_noification', handleNotification)
|
|
87
|
-
events.off('message_added_noification', handleMessageNotification)
|
|
88
|
-
}
|
|
89
|
-
}, [])
|
|
90
|
-
|
|
91
|
-
const handleUpdateOrder = useCallback(async (order: any) => {
|
|
92
|
-
if (order?.driver) {
|
|
68
|
+
const handleEventNotification = async (evtType: number, value: any) => {
|
|
69
|
+
if (value?.driver) {
|
|
93
70
|
const location = await getCurrentLocation()
|
|
94
71
|
await fetch(`${ordering.root}/users/${user.id}/locations`, {
|
|
95
72
|
method: 'POST',
|
|
@@ -98,25 +75,32 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
98
75
|
}),
|
|
99
76
|
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }
|
|
100
77
|
})
|
|
101
|
-
const assignedTimeDiff = moment.utc(
|
|
78
|
+
const assignedTimeDiff = moment.utc(value?.driver?.last_order_assigned_at).local().fromNow()
|
|
102
79
|
if (assignedTimeDiff === 'a few seconds ago') {
|
|
103
|
-
clearInterval(soundTimeout)
|
|
104
80
|
handlePlayNotificationSound()
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
setModalOpen(true)
|
|
108
|
-
}
|
|
81
|
+
clearInterval(soundTimeout)
|
|
82
|
+
setCurrentEvent({ evt: 2, orderId: value?.id })
|
|
109
83
|
}
|
|
84
|
+
return
|
|
110
85
|
}
|
|
111
|
-
|
|
86
|
+
handlePlayNotificationSound()
|
|
87
|
+
clearInterval(soundTimeout)
|
|
88
|
+
setCurrentEvent({
|
|
89
|
+
evt: evtType,
|
|
90
|
+
orderId: evtList[evtType].event === 'messages' ? value?.order_id : value?.id
|
|
91
|
+
})
|
|
92
|
+
}
|
|
112
93
|
|
|
113
94
|
useEffect(() => {
|
|
114
|
-
|
|
115
|
-
events.on('
|
|
95
|
+
events.on('message_added_notification', (o: any) => handleEventNotification(1, o))
|
|
96
|
+
events.on('order_added_notification', (o: any) => handleEventNotification(2, o))
|
|
97
|
+
events.on('order_updated_notification', (o: any) => handleEventNotification(3, o))
|
|
116
98
|
return () => {
|
|
117
|
-
events.off('
|
|
99
|
+
events.off('message_added_notification', (o: any) => handleEventNotification(1, o))
|
|
100
|
+
events.off('order_added_notification', (o: any) => handleEventNotification(2, o))
|
|
101
|
+
events.off('order_updated_notification', (o: any) => handleEventNotification(3, o))
|
|
118
102
|
}
|
|
119
|
-
}, [
|
|
103
|
+
}, [])
|
|
120
104
|
|
|
121
105
|
useEffect(() => {
|
|
122
106
|
notificationSound.setVolume(1);
|
|
@@ -125,21 +109,12 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
125
109
|
}
|
|
126
110
|
}, [])
|
|
127
111
|
|
|
128
|
-
useFocusEffect(
|
|
129
|
-
useCallback(() => {
|
|
130
|
-
setIsFocused(true)
|
|
131
|
-
return () => {
|
|
132
|
-
setIsFocused(false)
|
|
133
|
-
}
|
|
134
|
-
}, [])
|
|
135
|
-
)
|
|
136
|
-
|
|
137
112
|
return (
|
|
138
113
|
<>
|
|
139
114
|
<Modal
|
|
140
115
|
animationType='slide'
|
|
141
116
|
transparent={true}
|
|
142
|
-
visible={
|
|
117
|
+
visible={!!currentEvent?.orderId}
|
|
143
118
|
>
|
|
144
119
|
<NotificationContainer>
|
|
145
120
|
<View style={styles.modalView}>
|
|
@@ -147,40 +122,26 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
147
122
|
style={styles.wrapperIcon}
|
|
148
123
|
onPress={() => handleCloseModal()}
|
|
149
124
|
>
|
|
150
|
-
<Icon
|
|
151
|
-
name="x"
|
|
152
|
-
size={30}
|
|
153
|
-
/>
|
|
125
|
+
<Icon name="x" size={30} />
|
|
154
126
|
</TouchableOpacity>
|
|
155
127
|
<OText
|
|
156
128
|
size={18}
|
|
157
129
|
color={theme.colors.textGray}
|
|
158
130
|
weight={600}
|
|
159
131
|
>
|
|
160
|
-
{
|
|
132
|
+
{evtList[currentEvent?.evt]?.message}
|
|
161
133
|
</OText>
|
|
162
134
|
<OIcon
|
|
163
135
|
src={theme.images.general.newOrder}
|
|
164
136
|
width={250}
|
|
165
137
|
height={200}
|
|
166
138
|
/>
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
</OText>
|
|
174
|
-
)}
|
|
175
|
-
|
|
176
|
-
{messageOrderId !== null && (
|
|
177
|
-
<OText
|
|
178
|
-
color={theme.colors.textGray}
|
|
179
|
-
mBottom={15}
|
|
180
|
-
>
|
|
181
|
-
{t('ORDER_N_UNREAD_MESSAGES', 'Order #_order_id_ has unread messages.').replace('_order_id_', messageOrderId)}
|
|
182
|
-
</OText>
|
|
183
|
-
)}
|
|
139
|
+
<OText
|
|
140
|
+
color={theme.colors.textGray}
|
|
141
|
+
mBottom={15}
|
|
142
|
+
>
|
|
143
|
+
{evtList[currentEvent?.evt]?.message2}
|
|
144
|
+
</OText>
|
|
184
145
|
</View>
|
|
185
146
|
</NotificationContainer>
|
|
186
147
|
</Modal>
|
|
@@ -335,7 +335,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
335
335
|
addressName: order?.business?.address,
|
|
336
336
|
zipcode: order?.business?.zipcode
|
|
337
337
|
},
|
|
338
|
-
icon: order?.business?.logo ||
|
|
338
|
+
icon: order?.business?.logo || 'https://res.cloudinary.com/demo/image/fetch/c_thumb,g_face,r_max/https://res.cloudinary.com/ordering2/image/upload/v1654619525/hzegwosnplvrbtjkpfi6.png',
|
|
339
339
|
level: 2,
|
|
340
340
|
},
|
|
341
341
|
{
|
|
@@ -431,6 +431,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
431
431
|
handleViewSummaryOrder={handleViewSummaryOrder}
|
|
432
432
|
handleCopyClipboard={handleCopyClipboard}
|
|
433
433
|
handleArrowBack={handleArrowBack}
|
|
434
|
+
isCustomView={props.isCustomView}
|
|
434
435
|
/>
|
|
435
436
|
<OrderDetailsContainer
|
|
436
437
|
keyboardShouldPersistTaps="handled"
|
|
@@ -51,7 +51,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
51
51
|
orderTitle,
|
|
52
52
|
appTitle,
|
|
53
53
|
handleClickLogisticOrder,
|
|
54
|
-
forceUpdate
|
|
54
|
+
forceUpdate,
|
|
55
|
+
getPermissions
|
|
55
56
|
} = props;
|
|
56
57
|
const [, { showToast }] = useToast();
|
|
57
58
|
const { order } = props.order
|
|
@@ -101,9 +102,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
101
102
|
};
|
|
102
103
|
|
|
103
104
|
const handleOpenMapView = async () => {
|
|
104
|
-
|
|
105
|
+
const _permissions = await getPermissions()
|
|
106
|
+
|
|
107
|
+
const isBlocked = _permissions.some((_permission: string) => permissions?.locationStatus?.[_permission] === 'blocked')
|
|
108
|
+
const isGranted = _permissions.reduce((allPermissions: boolean, _permission: string) => allPermissions && permissions?.locationStatus?.[_permission] === 'granted', true)
|
|
109
|
+
|
|
110
|
+
if (isGranted) {
|
|
105
111
|
setOpenModalForMapView(!openModalForMapView);
|
|
106
|
-
} else if (
|
|
112
|
+
} else if (isBlocked) {
|
|
107
113
|
// redirectToSettings();
|
|
108
114
|
showToast(
|
|
109
115
|
ToastType.Error,
|
|
@@ -114,8 +120,9 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
114
120
|
);
|
|
115
121
|
} else {
|
|
116
122
|
const response = await askLocationPermission();
|
|
117
|
-
|
|
118
|
-
|
|
123
|
+
const isGranted = _permissions.reduce((allPermissions: boolean, _permission: string) => allPermissions && response?.locationStatus?.[_permission] === 'granted', true)
|
|
124
|
+
if (isGranted) {
|
|
125
|
+
setOpenModalForMapView(true)
|
|
119
126
|
}
|
|
120
127
|
}
|
|
121
128
|
};
|
|
@@ -141,9 +148,9 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
141
148
|
handleArrowBack()
|
|
142
149
|
}
|
|
143
150
|
|
|
144
|
-
const handleAcceptLogisticOrder = (order
|
|
151
|
+
const handleAcceptLogisticOrder = (order: any) => {
|
|
145
152
|
handleClickLogisticOrder?.(1, order?.logistic_order_id)
|
|
146
|
-
if(order?.order_group){
|
|
153
|
+
if (order?.order_group) {
|
|
147
154
|
handleArrowBack()
|
|
148
155
|
}
|
|
149
156
|
}
|
|
@@ -166,10 +173,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
166
173
|
];
|
|
167
174
|
|
|
168
175
|
useEffect(() => {
|
|
169
|
-
if (permissions
|
|
176
|
+
if (permissions?.locationStatus !== 'granted' && openModalForMapView) {
|
|
170
177
|
setOpenModalForMapView(false);
|
|
171
178
|
}
|
|
172
|
-
}, [permissions
|
|
179
|
+
}, [permissions?.locationStatus]);
|
|
173
180
|
|
|
174
181
|
useEffect(() => {
|
|
175
182
|
if (openModalForAccept) {
|
|
@@ -215,8 +222,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
215
222
|
}, [messagesReadList]);
|
|
216
223
|
|
|
217
224
|
useEffect(() => {
|
|
218
|
-
forceUpdate && handleViewActionOrder && handleViewActionOrder(forceUpdate === 9 ? 'forcePickUp': 'forceDelivery')
|
|
219
|
-
},[forceUpdate])
|
|
225
|
+
forceUpdate && handleViewActionOrder && handleViewActionOrder(forceUpdate === 9 ? 'forcePickUp' : 'forceDelivery')
|
|
226
|
+
}, [forceUpdate])
|
|
220
227
|
|
|
221
228
|
const styles = StyleSheet.create({
|
|
222
229
|
btnPickUp: {
|
|
@@ -254,7 +261,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
254
261
|
);
|
|
255
262
|
}
|
|
256
263
|
|
|
257
|
-
const OrderDetailsInformation = (props
|
|
264
|
+
const OrderDetailsInformation = (props: { order: any, isOrderGroup?: boolean, lastOrder?: boolean }) => {
|
|
258
265
|
const {
|
|
259
266
|
order,
|
|
260
267
|
isOrderGroup,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
Table,
|
|
12
12
|
OrderBill,
|
|
13
13
|
Total,
|
|
14
|
+
OSRow,
|
|
14
15
|
} from './styles';
|
|
15
16
|
|
|
16
17
|
import { ProductItemAccordion } from '../ProductItemAccordion';
|
|
@@ -75,11 +76,52 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
75
76
|
}
|
|
76
77
|
})
|
|
77
78
|
|
|
79
|
+
const getIncludedTaxes = () => {
|
|
80
|
+
if (order?.taxes?.length === 0) {
|
|
81
|
+
return order.tax_type === 1 ? order?.summary?.tax ?? 0 : 0
|
|
82
|
+
} else {
|
|
83
|
+
return order?.taxes.reduce((taxIncluded: number, tax: any) => {
|
|
84
|
+
return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
|
|
85
|
+
}, 0)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const getIncludedTaxesDiscounts = () => {
|
|
90
|
+
return order?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
|
|
91
|
+
}
|
|
92
|
+
|
|
78
93
|
return (
|
|
79
94
|
<OrderContent isOrderGroup={isOrderGroup} lastOrder={lastOrder}>
|
|
80
95
|
{isOrderGroup && (
|
|
81
96
|
<OText size={18}>{t('ORDER', 'Order')} #{isOrderGroup ? order?.order_group_id : order?.id}</OText>
|
|
82
97
|
)}
|
|
98
|
+
|
|
99
|
+
{order?.metafields?.length > 0 && (
|
|
100
|
+
<OrderBusiness>
|
|
101
|
+
<OText style={{ marginBottom: 5 }} size={16} weight="600">
|
|
102
|
+
{t('CUSTOM_FIELDS', 'Custom fields')}
|
|
103
|
+
</OText>
|
|
104
|
+
|
|
105
|
+
{order.metafields.map((field: any) => (
|
|
106
|
+
<View
|
|
107
|
+
key={field.id}
|
|
108
|
+
style={{
|
|
109
|
+
width: '100%',
|
|
110
|
+
flexDirection: 'row',
|
|
111
|
+
marginBottom: 5
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
<OText style={{ width: '50%' }}>
|
|
115
|
+
{field.key}
|
|
116
|
+
</OText>
|
|
117
|
+
<OText style={{ width: '45%', textAlign: 'right' }}>
|
|
118
|
+
{field.value}
|
|
119
|
+
</OText>
|
|
120
|
+
</View>
|
|
121
|
+
))}
|
|
122
|
+
</OrderBusiness>
|
|
123
|
+
)}
|
|
124
|
+
|
|
83
125
|
<OrderBusiness>
|
|
84
126
|
<OText style={{ marginBottom: 5 }} size={16} weight="600">
|
|
85
127
|
{t('BUSINESS_DETAILS', 'Business details')}
|
|
@@ -281,14 +323,14 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
281
323
|
</OText>
|
|
282
324
|
)}
|
|
283
325
|
{((order?.delivery_option !== undefined && order?.delivery_type === 1) || !!order?.comment) && (
|
|
284
|
-
<View style={{marginTop: 10}}>
|
|
326
|
+
<View style={{ marginTop: 10 }}>
|
|
285
327
|
{order?.delivery_option !== undefined && order?.delivery_type === 1 && (
|
|
286
328
|
<OText>
|
|
287
329
|
{order?.delivery_option?.name}
|
|
288
330
|
</OText>
|
|
289
331
|
)}
|
|
290
332
|
{!!order?.comment && (
|
|
291
|
-
<OText style={{fontStyle: 'italic', opacity: 0.6, marginBottom: 5}}>
|
|
333
|
+
<OText style={{ fontStyle: 'italic', opacity: 0.6, marginBottom: 5 }}>
|
|
292
334
|
{order?.comment}
|
|
293
335
|
</OText>
|
|
294
336
|
)}
|
|
@@ -323,84 +365,109 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
323
365
|
<Table>
|
|
324
366
|
<OText mBottom={4}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
325
367
|
<OText mBottom={4}>
|
|
326
|
-
{parsePrice(
|
|
327
|
-
order.tax_type === 1
|
|
328
|
-
? order?.summary?.subtotal + order?.summary?.tax ?? 0
|
|
329
|
-
: order?.summary?.subtotal ?? 0,
|
|
330
|
-
)}
|
|
368
|
+
{parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()))}
|
|
331
369
|
</OText>
|
|
332
370
|
</Table>
|
|
333
|
-
|
|
334
|
-
|
|
371
|
+
{(order?.summary?.discount > 0 ?? order?.discount > 0) && order?.offers?.length === 0 && (
|
|
372
|
+
<Table>
|
|
373
|
+
{order?.offer_type === 1 ? (
|
|
374
|
+
<OText mBottom={4}>
|
|
375
|
+
{t('DISCOUNT', theme?.defaultLanguages?.DISCOUNT || 'Discount')}{' '}
|
|
376
|
+
<OText>{`(${verifyDecimals(order?.offer_rate, parsePrice)}%)`}</OText>
|
|
377
|
+
</OText>
|
|
378
|
+
) : (
|
|
379
|
+
<OText mBottom={4}>{t('DISCOUNT', theme?.defaultLanguages?.DISCOUNT || 'Discount')}</OText>
|
|
380
|
+
)}
|
|
381
|
+
<OText>- {parsePrice(order?.summary?.discount ?? order?.discount)}</OText>
|
|
382
|
+
</Table>
|
|
383
|
+
)}
|
|
384
|
+
{
|
|
385
|
+
order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
|
|
386
|
+
<Table key={offer.id}>
|
|
387
|
+
<OSRow>
|
|
388
|
+
<OText mBottom={4}>
|
|
389
|
+
{offer.name}
|
|
390
|
+
{offer.rate_type === 1 && (
|
|
391
|
+
<OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
392
|
+
)}
|
|
393
|
+
</OText>
|
|
394
|
+
</OSRow>
|
|
395
|
+
<OText mBottom={4}>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
396
|
+
</Table>
|
|
397
|
+
))
|
|
398
|
+
}
|
|
399
|
+
{order?.summary?.subtotal_with_discount > 0 && order?.summary?.discount > 0 && order?.summary?.total >= 0 && (
|
|
400
|
+
<Table>
|
|
401
|
+
<OText mBottom={4}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
|
|
402
|
+
{order?.tax_type === 1 ? (
|
|
403
|
+
<OText mBottom={4}>{parsePrice((order?.summary?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0))}</OText>
|
|
404
|
+
) : (
|
|
405
|
+
<OText mBottom={4}>{parsePrice(order?.summary?.subtotal_with_discount ?? 0)}</OText>
|
|
406
|
+
)}
|
|
407
|
+
</Table>
|
|
408
|
+
)}
|
|
409
|
+
{order?.taxes?.length === 0 && order?.tax_type === 2 && order?.summary?.tax > 0 && (
|
|
335
410
|
<Table>
|
|
336
411
|
<OText mBottom={4}>
|
|
337
|
-
{t('TAX', 'Tax')}
|
|
338
|
-
{`(${verifyDecimals(
|
|
339
|
-
order?.summary?.tax_rate,
|
|
340
|
-
parseNumber,
|
|
341
|
-
)}%)`}
|
|
412
|
+
{t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
|
|
342
413
|
</OText>
|
|
343
|
-
|
|
344
414
|
<OText mBottom={4}>
|
|
345
415
|
{parsePrice(order?.summary?.tax ?? 0)}
|
|
346
416
|
</OText>
|
|
347
|
-
</Table
|
|
417
|
+
</Table>
|
|
348
418
|
)}
|
|
349
|
-
|
|
350
419
|
{
|
|
351
|
-
order?.summary?.
|
|
420
|
+
order?.fees?.length === 0 && order?.summary?.service_fee > 0 && (
|
|
352
421
|
<Table>
|
|
353
|
-
{order?.offer_type === 1 ? (
|
|
354
|
-
<OText mBottom={4}>
|
|
355
|
-
<OText>{t('DISCOUNT', 'Discount')}</OText>
|
|
356
|
-
|
|
357
|
-
<OText>
|
|
358
|
-
{`(${verifyDecimals(
|
|
359
|
-
order?.offer_rate,
|
|
360
|
-
parsePrice,
|
|
361
|
-
)}%)`}
|
|
362
|
-
</OText>
|
|
363
|
-
</OText>
|
|
364
|
-
) : (
|
|
365
|
-
<OText mBottom={4}>{t('DISCOUNT', 'Discount')}</OText>
|
|
366
|
-
)}
|
|
367
|
-
|
|
368
422
|
<OText mBottom={4}>
|
|
369
|
-
|
|
423
|
+
{t('SERVICE_FEE', 'Service fee')}
|
|
424
|
+
{`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
|
|
370
425
|
</OText>
|
|
426
|
+
<OText mBottom={4}>{parsePrice(order?.summary?.service_fee ?? 0)}</OText>
|
|
371
427
|
</Table>
|
|
372
428
|
)
|
|
373
429
|
}
|
|
374
|
-
|
|
375
430
|
{
|
|
376
|
-
order?.
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
<Table>
|
|
380
|
-
<OText mBottom={4}>
|
|
381
|
-
{t(
|
|
382
|
-
'SUBTOTAL_WITH_DISCOUNT',
|
|
383
|
-
'Subtotal with discount',
|
|
384
|
-
)}
|
|
385
|
-
</OText>
|
|
386
|
-
{order?.tax_type === 1 ? (
|
|
431
|
+
order?.taxes?.length > 0 && order?.taxes?.filter((tax: any) => tax?.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
432
|
+
<Table key={tax.id}>
|
|
433
|
+
<OSRow>
|
|
387
434
|
<OText mBottom={4}>
|
|
388
|
-
{
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
435
|
+
{tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
436
|
+
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
437
|
+
</OText>
|
|
438
|
+
</OSRow>
|
|
439
|
+
<OText mBottom={4}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
|
|
440
|
+
</Table>
|
|
441
|
+
))
|
|
442
|
+
}
|
|
443
|
+
{
|
|
444
|
+
order?.fees?.length > 0 && order?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0))?.map((fee: any) => (
|
|
445
|
+
<Table key={fee.id}>
|
|
446
|
+
<OSRow>
|
|
447
|
+
<OText mBottom={4}>
|
|
448
|
+
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
449
|
+
({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%){' '}
|
|
392
450
|
</OText>
|
|
393
|
-
|
|
451
|
+
</OSRow>
|
|
452
|
+
<OText mBottom={4}>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
|
|
453
|
+
</Table>
|
|
454
|
+
))
|
|
455
|
+
}
|
|
456
|
+
{
|
|
457
|
+
order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
|
|
458
|
+
<Table key={offer.id}>
|
|
459
|
+
<OSRow>
|
|
394
460
|
<OText mBottom={4}>
|
|
395
|
-
{
|
|
396
|
-
|
|
461
|
+
{offer.name}
|
|
462
|
+
{offer.rate_type === 1 && (
|
|
463
|
+
<OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
397
464
|
)}
|
|
398
465
|
</OText>
|
|
399
|
-
|
|
466
|
+
</OSRow>
|
|
467
|
+
<OText mBottom={4}>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
400
468
|
</Table>
|
|
401
|
-
)
|
|
469
|
+
))
|
|
402
470
|
}
|
|
403
|
-
|
|
404
471
|
{
|
|
405
472
|
order?.summary?.delivery_price > 0 && (
|
|
406
473
|
<Table>
|
|
@@ -414,41 +481,35 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
414
481
|
</Table>
|
|
415
482
|
)
|
|
416
483
|
}
|
|
417
|
-
|
|
418
|
-
<Table>
|
|
419
|
-
<OText mBottom={4}>
|
|
420
|
-
{t('DRIVER_TIP', 'Driver tip')}{' '}
|
|
421
|
-
{order?.summary?.driver_tip > 0 &&
|
|
422
|
-
parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
|
|
423
|
-
!parseInt(configs?.driver_tip_use_custom?.value, 10) &&
|
|
424
|
-
`(${verifyDecimals(
|
|
425
|
-
order?.summary?.driver_tip,
|
|
426
|
-
parseNumber,
|
|
427
|
-
)}%)`}
|
|
428
|
-
</OText>
|
|
429
|
-
|
|
430
|
-
<OText mBottom={4}>
|
|
431
|
-
{parsePrice(order?.summary?.driver_tip ?? 0)}
|
|
432
|
-
</OText>
|
|
433
|
-
</Table>
|
|
434
|
-
|
|
435
484
|
{
|
|
436
|
-
order?.
|
|
437
|
-
<Table>
|
|
438
|
-
<
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
<OText mBottom={4}>
|
|
447
|
-
{parsePrice(order?.summary?.service_fee)}
|
|
448
|
-
</OText>
|
|
485
|
+
order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
|
|
486
|
+
<Table key={offer.id}>
|
|
487
|
+
<OSRow>
|
|
488
|
+
<OText mBottom={4}>
|
|
489
|
+
{offer.name}
|
|
490
|
+
{offer.rate_type === 1 && (
|
|
491
|
+
<OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
492
|
+
)}
|
|
493
|
+
</OText>
|
|
494
|
+
</OSRow>
|
|
495
|
+
<OText mBottom={4}>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
449
496
|
</Table>
|
|
450
|
-
)
|
|
497
|
+
))
|
|
451
498
|
}
|
|
499
|
+
{order?.summary?.driver_tip > 0 && (
|
|
500
|
+
<Table>
|
|
501
|
+
<OText mBottom={4}>
|
|
502
|
+
{t('DRIVER_TIP', 'Driver tip')}
|
|
503
|
+
{order?.summary?.driver_tip > 0 &&
|
|
504
|
+
parseInt(configs?.driver_tip_type?.value, 10) === 2 &&
|
|
505
|
+
!parseInt(configs?.driver_tip_use_custom?.value, 10) &&
|
|
506
|
+
(
|
|
507
|
+
`(${verifyDecimals(order?.summary?.driver_tip, parseNumber)}%)`
|
|
508
|
+
)}
|
|
509
|
+
</OText>
|
|
510
|
+
<OText mBottom={4}>{parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip)}</OText>
|
|
511
|
+
</Table>
|
|
512
|
+
)}
|
|
452
513
|
|
|
453
514
|
<Total style={{ paddingBottom: 10 }}>
|
|
454
515
|
<Table>
|
|
@@ -460,7 +521,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
460
521
|
mBottom={4}
|
|
461
522
|
style={styles.textBold}
|
|
462
523
|
color={theme.colors.primary}>
|
|
463
|
-
{parsePrice(order?.summary?.total ??
|
|
524
|
+
{parsePrice(order?.summary?.total ?? order?.total)}
|
|
464
525
|
</OText>
|
|
465
526
|
</Table>
|
|
466
527
|
</Total>
|