ordering-ui-react-native 0.17.3-release → 0.17.4-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 +1 -1
- package/themes/original/src/components/MultiCheckout/index.tsx +1 -1
- package/themes/original/src/components/OrderDetails/OrderEta.tsx +5 -4
- package/themes/original/src/components/OrderDetails/index.tsx +1 -1
- package/themes/original/src/components/OrdersOption/index.tsx +26 -7
- package/themes/original/src/components/SingleOrderCard/index.tsx +29 -12
- package/themes/original/src/components/SingleOrderCard/styles.tsx +1 -1
- package/themes/original/src/types/index.tsx +1 -1
package/package.json
CHANGED
|
@@ -36,10 +36,11 @@ export const OrderEta = (props: any) => {
|
|
|
36
36
|
if (diffTimeAsMinutes <= 0) {
|
|
37
37
|
totalEta += (Math.floor(Math.abs(diffTimeAsMinutes / order?.eta_current_status_time) + 1) * order?.eta_current_status_penalty_time)
|
|
38
38
|
}
|
|
39
|
-
_estimatedTime =
|
|
39
|
+
_estimatedTime = moment.utc(_delivery).add(totalEta, 'minutes')
|
|
40
40
|
} else {
|
|
41
|
-
_estimatedTime =
|
|
41
|
+
_estimatedTime = moment.utc(_delivery).add(order?.eta_time, 'minutes')
|
|
42
42
|
}
|
|
43
|
+
_estimatedTime = outputFormat ? moment(_estimatedTime).format(outputFormat) : parseDate(_estimatedTime, { utc: false })
|
|
43
44
|
setEstimatedDeliveryTime(_estimatedTime)
|
|
44
45
|
}
|
|
45
46
|
|
|
@@ -49,11 +50,11 @@ export const OrderEta = (props: any) => {
|
|
|
49
50
|
getEstimatedDeliveryTime()
|
|
50
51
|
}, 1000)
|
|
51
52
|
return () => clearInterval(interval)
|
|
52
|
-
}, [order])
|
|
53
|
+
}, [order, outputFormat])
|
|
53
54
|
|
|
54
55
|
return (
|
|
55
56
|
<>
|
|
56
|
-
{
|
|
57
|
+
{estimatedDeliveryTime}
|
|
57
58
|
</>
|
|
58
59
|
)
|
|
59
60
|
}
|
|
@@ -121,7 +121,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
121
121
|
const mapValidStatuses = [9, 19, 23]
|
|
122
122
|
const placeSpotTypes = [3, 4, 5]
|
|
123
123
|
const directionTypes = [2, 3, 4, 5]
|
|
124
|
-
const activeStatus = [0, 3, 4, 7, 8, 9, 14, 18, 19, 20, 21, 22, 23]
|
|
124
|
+
const activeStatus = [0, 3, 4, 7, 8, 9, 13, 14, 18, 19, 20, 21, 22, 23]
|
|
125
125
|
const enabledPoweredByOrdering = configs?.powered_by_ordering_module?.value
|
|
126
126
|
const hideDeliveryDate = theme?.confirmation?.components?.order?.components?.date?.hidden
|
|
127
127
|
const isGiftCardOrder = !order?.business_id
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "rn-placeholder";
|
|
18
18
|
|
|
19
19
|
import { View, ScrollView } from 'react-native'
|
|
20
|
-
import { getOrderStatus } from '../../utils'
|
|
20
|
+
import { getOrderStatus, flatArray } from '../../utils'
|
|
21
21
|
|
|
22
22
|
const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
23
23
|
const {
|
|
@@ -120,6 +120,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
useEffect(() => {
|
|
123
|
+
if (reorderState?.loading) return
|
|
123
124
|
const _businessId = 'businessId:' + reorderState?.result?.business_id
|
|
124
125
|
if (reorderState?.error) {
|
|
125
126
|
if (reorderState?.result?.business_id) {
|
|
@@ -127,21 +128,39 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
127
128
|
navigation.navigate('Business', { store: reorderState?.result?.business?.slug })
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
|
-
if (!reorderState?.error && reorderState.loading
|
|
131
|
+
if (!reorderState?.error && !reorderState.loading && reorderState?.result?.business_id) {
|
|
131
132
|
const cartProducts = carts?.[_businessId]?.products
|
|
132
|
-
const available = cartProducts.every((product: any) => product.valid === true)
|
|
133
|
-
const orderProducts = orders.find((order: any) => order?.id === reorderState?.result?.orderId)?.products
|
|
134
133
|
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
const available = cartProducts.every((product: any) => product.valid)
|
|
135
|
+
const orderProducts = orders.find(
|
|
136
|
+
(order: any) => Array.isArray(order?.id)
|
|
137
|
+
? order?.id?.includes(reorderState?.result?.orderId)
|
|
138
|
+
: order?.id === reorderState?.result?.orderId
|
|
139
|
+
)?.products
|
|
140
|
+
|
|
141
|
+
const productsFlatten = orderProducts?.length && flatArray(orderProducts)?.filter(product => product?.order_id === reorderState?.result?.orderId)
|
|
142
|
+
|
|
143
|
+
if (available && reorderState?.result?.uuid && (cartProducts?.length === productsFlatten?.length)) {
|
|
144
|
+
const multiOrders = flatArray(orderProducts)?.map(product => product.order_id)
|
|
145
|
+
const params = multiOrders?.length > 1
|
|
146
|
+
? { screen: 'MultiCheckout', checkCarts: true }
|
|
147
|
+
: { cartUuid: reorderState?.result.uuid }
|
|
148
|
+
|
|
149
|
+
onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', params)
|
|
137
150
|
} else {
|
|
138
151
|
_setStoreData('adjust-cart-products', JSON.stringify(_businessId))
|
|
139
|
-
cartProducts?.length !==
|
|
152
|
+
cartProducts?.length !== productsFlatten?.length && _setStoreData('already-removed', JSON.stringify('removed'))
|
|
140
153
|
navigation.navigate('Business', { store: reorderState?.result?.business?.slug })
|
|
141
154
|
}
|
|
142
155
|
}
|
|
143
156
|
}, [reorderState])
|
|
144
157
|
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (reorderState?.error) {
|
|
160
|
+
showToast(ToastType.Error, reorderState?.result)
|
|
161
|
+
}
|
|
162
|
+
}, [reorderState])
|
|
163
|
+
|
|
145
164
|
useFocusEffect(
|
|
146
165
|
React.useCallback(() => {
|
|
147
166
|
if (!businessesSearchList) {
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
useOrder,
|
|
6
6
|
useLanguage
|
|
7
7
|
} from 'ordering-components/native';
|
|
8
|
+
import FastImage from 'react-native-fast-image'
|
|
8
9
|
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
9
10
|
import { useTheme } from 'styled-components/native';
|
|
10
11
|
import { OIcon, OText, OButton } from '../shared';
|
|
@@ -45,7 +46,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
45
46
|
const [{ carts }] = useOrder()
|
|
46
47
|
const theme = useTheme();
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
let [reorderSelected, setReorderSelected] = useState<number | null>(null);
|
|
49
50
|
const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
|
|
50
51
|
const [isPressed, setIsPressed] = useState(false)
|
|
51
52
|
|
|
@@ -128,19 +129,29 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
128
129
|
});
|
|
129
130
|
|
|
130
131
|
const handleReorderClick = (order: any) => {
|
|
131
|
-
|
|
132
|
+
setReorderSelected(null)
|
|
133
|
+
reorderSelected = null
|
|
134
|
+
const isMultiOrders = Array.isArray(order?.id)
|
|
135
|
+
|
|
136
|
+
const isRemoveCart = isMultiOrders
|
|
137
|
+
? order?.business_id?.some((businessId: any) => !!carts[`businessId:${businessId}`]?.uuid)
|
|
138
|
+
: carts[`businessId:${order?.business_id}`] && !!carts[`businessId:${order?.business_id}`]?.uuid
|
|
139
|
+
|
|
140
|
+
if (isRemoveCart) {
|
|
132
141
|
setConfirm({
|
|
133
142
|
open: true,
|
|
134
143
|
content: [t('QUESTION_DELETE_PRODUCTS_FROM_CART', 'Are you sure that you want to delete all products from cart?')],
|
|
135
144
|
title: t('ORDER', 'Order'),
|
|
136
145
|
handleOnAccept: async () => {
|
|
137
|
-
handleRemoveCart()
|
|
146
|
+
handleRemoveCart(order)
|
|
138
147
|
setConfirm({ ...confirm, open: false })
|
|
139
148
|
}
|
|
140
149
|
})
|
|
141
150
|
} else {
|
|
142
|
-
|
|
143
|
-
|
|
151
|
+
const orderId = Array.isArray(order?.id) ? order?.id[0] : order?.id
|
|
152
|
+
setReorderSelected(orderId)
|
|
153
|
+
reorderSelected = orderId
|
|
154
|
+
handleReorder && handleReorder(order?.id)
|
|
144
155
|
}
|
|
145
156
|
};
|
|
146
157
|
|
|
@@ -215,10 +226,13 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
215
226
|
key={business?.id}
|
|
216
227
|
style={styles.logoWrapper}
|
|
217
228
|
>
|
|
218
|
-
<
|
|
219
|
-
url={optimizeImage(business?.logo, 'h_300,c_limit')}
|
|
220
|
-
src={optimizeImage(!business?.logo && theme?.images?.dummies?.businessLogo, 'h_300,c_limit')}
|
|
229
|
+
<FastImage
|
|
221
230
|
style={styles.minilogo}
|
|
231
|
+
source={business?.logo ? {
|
|
232
|
+
uri: optimizeImage(business?.logo, 'h_300,c_limit'),
|
|
233
|
+
priority: FastImage.priority.normal,
|
|
234
|
+
} : theme?.images?.dummies?.businessLogo}
|
|
235
|
+
resizeMode={FastImage.resizeMode.contain}
|
|
222
236
|
/>
|
|
223
237
|
</Logo>
|
|
224
238
|
))}
|
|
@@ -228,10 +242,13 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
228
242
|
</MultiLogosContainer>
|
|
229
243
|
) : (
|
|
230
244
|
<Logo style={styles.logoWrapper}>
|
|
231
|
-
<
|
|
232
|
-
url={optimizeImage(order.business?.logo, 'h_300,c_limit')}
|
|
233
|
-
src={optimizeImage(!order.business?.logo && theme?.images?.dummies?.businessLogo, 'h_300,c_limit')}
|
|
245
|
+
<FastImage
|
|
234
246
|
style={styles.logo}
|
|
247
|
+
source={order.business?.logo ? {
|
|
248
|
+
uri: optimizeImage(order.business?.logo, 'h_300,c_limit'),
|
|
249
|
+
priority: FastImage.priority.normal,
|
|
250
|
+
} : theme?.images?.dummies?.businessLogo}
|
|
251
|
+
resizeMode={FastImage.resizeMode.contain}
|
|
235
252
|
/>
|
|
236
253
|
</Logo>
|
|
237
254
|
)}
|
|
@@ -280,7 +297,7 @@ const SingleOrderCardUI = (props: SingleOrderCardParams) => {
|
|
|
280
297
|
</OText>
|
|
281
298
|
</TouchableOpacity>
|
|
282
299
|
)}
|
|
283
|
-
{!hideReorderButton && (
|
|
300
|
+
{!hideReorderButton && typeof order?.id === 'number' && (
|
|
284
301
|
<OButton
|
|
285
302
|
text={t('REORDER', 'Reorder')}
|
|
286
303
|
imgRightSrc={''}
|