ordering-ui-react-native 0.17.83 → 0.17.85
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/ProductItemAccordion/index.tsx +1 -1
- package/themes/original/src/components/Cart/index.tsx +27 -4
- package/themes/original/src/components/CartContent/index.tsx +5 -1
- package/themes/original/src/components/FavoriteList/index.tsx +1 -35
- package/themes/original/src/components/LastOrder/index.tsx +1 -34
- package/themes/original/src/components/MessageListing/index.tsx +1 -34
- package/themes/original/src/components/MultiCheckout/index.tsx +87 -64
- package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +37 -224
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +31 -2
- package/themes/original/src/components/MultiOrdersDetails/styles.tsx +1 -1
- package/themes/original/src/components/MyOrders/index.tsx +5 -3
- package/themes/original/src/components/OrderDetails/index.tsx +1 -200
- package/themes/original/src/components/OrderProgress/index.tsx +2 -34
- package/themes/original/src/components/OrdersOption/index.tsx +1 -34
- package/themes/original/src/components/Wallets/index.tsx +44 -10
- package/themes/original/src/utils/index.tsx +203 -1
package/package.json
CHANGED
|
@@ -288,7 +288,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
|
|
|
288
288
|
color={theme.colors.unselectText}>
|
|
289
289
|
{t('COMMENT', 'Comment')}
|
|
290
290
|
</OText>
|
|
291
|
-
<OText size={12} mLeft={10} color={theme.colors.unselectText}>
|
|
291
|
+
<OText size={12} mLeft={10} style={{ width: '100%' }} color={theme.colors.unselectText}>
|
|
292
292
|
{product.comment}
|
|
293
293
|
</OText>
|
|
294
294
|
</ProductComment>
|
|
@@ -41,7 +41,10 @@ const CartUI = (props: any) => {
|
|
|
41
41
|
commentState,
|
|
42
42
|
onNavigationRedirect,
|
|
43
43
|
handleRemoveOfferClick,
|
|
44
|
-
isMultiCheckout
|
|
44
|
+
isMultiCheckout,
|
|
45
|
+
hideDeliveryFee,
|
|
46
|
+
hideDriverTip,
|
|
47
|
+
showGeneralBtn
|
|
45
48
|
} = props
|
|
46
49
|
|
|
47
50
|
const theme = useTheme();
|
|
@@ -191,6 +194,26 @@ const CartUI = (props: any) => {
|
|
|
191
194
|
|
|
192
195
|
return (
|
|
193
196
|
<CContainer>
|
|
197
|
+
{showGeneralBtn && cart?.valid_products &&(
|
|
198
|
+
<CheckoutAction style={{ marginTop: 0 }}>
|
|
199
|
+
<OButton
|
|
200
|
+
text={(subtotalWithTaxes >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
|
|
201
|
+
!openUpselling !== canOpenUpselling ? t('CHECKOUT', 'Checkout') : t('LOADING', 'Loading')
|
|
202
|
+
) : !cart?.valid_address ? (
|
|
203
|
+
`${t('OUT_OF_COVERAGE', 'Out of Coverage')}`
|
|
204
|
+
) : (
|
|
205
|
+
`${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`
|
|
206
|
+
)}
|
|
207
|
+
bgColor={(subtotalWithTaxes < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
|
|
208
|
+
isDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
|
|
209
|
+
borderColor={theme.colors.primary}
|
|
210
|
+
imgRightSrc={null}
|
|
211
|
+
textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
|
|
212
|
+
onClick={() => handleUpsellingPage()}
|
|
213
|
+
style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
|
|
214
|
+
/>
|
|
215
|
+
</CheckoutAction>
|
|
216
|
+
)}
|
|
194
217
|
{openUpselling && (
|
|
195
218
|
<UpsellingProducts
|
|
196
219
|
handleUpsellingPage={handleUpsellingPage}
|
|
@@ -337,10 +360,10 @@ const CartUI = (props: any) => {
|
|
|
337
360
|
</OSTable>
|
|
338
361
|
))
|
|
339
362
|
}
|
|
340
|
-
{orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
|
|
363
|
+
{orderState?.options?.type === 1 && cart?.delivery_price > 0 && !hideDeliveryFee && (
|
|
341
364
|
<OSTable>
|
|
342
365
|
<OText size={12} lineHeight={18}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
|
|
343
|
-
<OText size={12} lineHeight={18}>{parsePrice(cart?.delivery_price)}</OText>
|
|
366
|
+
<OText size={12} lineHeight={18}>{parsePrice(cart?.delivery_price_with_discount ?? cart?.delivery_price)}</OText>
|
|
344
367
|
</OSTable>
|
|
345
368
|
)}
|
|
346
369
|
{
|
|
@@ -364,7 +387,7 @@ const CartUI = (props: any) => {
|
|
|
364
387
|
</OSTable>
|
|
365
388
|
))
|
|
366
389
|
}
|
|
367
|
-
{cart?.driver_tip > 0 && (
|
|
390
|
+
{cart?.driver_tip > 0 && !hideDriverTip && (
|
|
368
391
|
<OSTable>
|
|
369
392
|
<OText size={12} lineHeight={18}>
|
|
370
393
|
{t('DRIVER_TIP', 'Driver tip')}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
|
-
import { useLanguage } from 'ordering-components/native';
|
|
3
|
+
import { useLanguage, useConfig } from 'ordering-components/native';
|
|
4
4
|
import { useTheme } from 'styled-components/native';
|
|
5
5
|
import { CCContainer, CCNotCarts, CCList } from './styles';
|
|
6
6
|
|
|
@@ -17,9 +17,11 @@ export const CartContent = (props: any) => {
|
|
|
17
17
|
|
|
18
18
|
const theme = useTheme();
|
|
19
19
|
const [, t] = useLanguage()
|
|
20
|
+
const [{ configs }] = useConfig()
|
|
20
21
|
const [isCartsLoading, setIsCartsLoading] = useState(false)
|
|
21
22
|
|
|
22
23
|
const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
|
|
24
|
+
const isMultiCheckout = configs?.checkout_multi_business_enabled?.value === '1'
|
|
23
25
|
|
|
24
26
|
return (
|
|
25
27
|
<CCContainer
|
|
@@ -32,6 +34,7 @@ export const CartContent = (props: any) => {
|
|
|
32
34
|
{cart.products.length > 0 && (
|
|
33
35
|
<>
|
|
34
36
|
<Cart
|
|
37
|
+
showGeneralBtn={i === 0 && isMultiCheckout}
|
|
35
38
|
singleBusiness={props.singleBusiness}
|
|
36
39
|
isFranchiseApp={props.isFranchiseApp}
|
|
37
40
|
cart={cart}
|
|
@@ -39,6 +42,7 @@ export const CartContent = (props: any) => {
|
|
|
39
42
|
onNavigationRedirect={props.onNavigationRedirect}
|
|
40
43
|
isCartsLoading={isCartsLoading}
|
|
41
44
|
setIsCartsLoading={setIsCartsLoading}
|
|
45
|
+
isMultiCheckout={isMultiCheckout}
|
|
42
46
|
hideUpselling
|
|
43
47
|
/>
|
|
44
48
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40, marginTop: 20 }} />
|
|
@@ -16,7 +16,7 @@ import { BusinessController } from '../BusinessController';
|
|
|
16
16
|
import { SingleProductCard } from '../SingleProductCard';
|
|
17
17
|
import { NotFoundSource } from '../NotFoundSource';
|
|
18
18
|
import moment from 'moment';
|
|
19
|
-
|
|
19
|
+
import { getOrderStatus } from '../../utils'
|
|
20
20
|
|
|
21
21
|
const FavoriteListUI = (props: FavoriteParams) => {
|
|
22
22
|
const {
|
|
@@ -40,40 +40,6 @@ const FavoriteListUI = (props: FavoriteParams) => {
|
|
|
40
40
|
|
|
41
41
|
const pastOrders = [1, 2, 5, 6, 10, 11, 12, 15, 16, 17]
|
|
42
42
|
|
|
43
|
-
const getOrderStatus = (s: any) => {
|
|
44
|
-
const status = parseInt(s)
|
|
45
|
-
const orderStatus = [
|
|
46
|
-
{ key: 0, value: t('PENDING', theme?.defaultLanguages?.PENDING || 'Pending') },
|
|
47
|
-
{ key: 1, value: t('COMPLETED', theme?.defaultLanguages?.COMPLETED || 'Completed') },
|
|
48
|
-
{ key: 2, value: t('REJECTED', theme?.defaultLanguages?.REJECTED || 'Rejected') },
|
|
49
|
-
{ key: 3, value: t('DRIVER_IN_BUSINESS', theme?.defaultLanguages?.DRIVER_IN_BUSINESS || 'Driver in business') },
|
|
50
|
-
{ key: 4, value: t('PREPARATION_COMPLETED', theme?.defaultLanguages?.PREPARATION_COMPLETED || 'Preparation Completed') },
|
|
51
|
-
{ key: 5, value: t('REJECTED_BY_BUSINESS', theme?.defaultLanguages?.REJECTED_BY_BUSINESS || 'Rejected by business') },
|
|
52
|
-
{ key: 6, value: t('REJECTED_BY_DRIVER', theme?.defaultLanguages?.REJECTED_BY_DRIVER || 'Rejected by Driver') },
|
|
53
|
-
{ key: 7, value: t('ACCEPTED_BY_BUSINESS', theme?.defaultLanguages?.ACCEPTED_BY_BUSINESS || 'Accepted by business') },
|
|
54
|
-
{ key: 8, value: t('ACCEPTED_BY_DRIVER', theme?.defaultLanguages?.ACCEPTED_BY_DRIVER || 'Accepted by driver') },
|
|
55
|
-
{ key: 9, value: t('PICK_UP_COMPLETED_BY_DRIVER', theme?.defaultLanguages?.PICK_UP_COMPLETED_BY_DRIVER || 'Pick up completed by driver') },
|
|
56
|
-
{ key: 10, value: t('PICK_UP_FAILED_BY_DRIVER', theme?.defaultLanguages?.PICK_UP_FAILED_BY_DRIVER || 'Pick up Failed by driver') },
|
|
57
|
-
{ key: 11, value: t('DELIVERY_COMPLETED_BY_DRIVER', theme?.defaultLanguages?.DELIVERY_COMPLETED_BY_DRIVER || 'Delivery completed by driver') },
|
|
58
|
-
{ key: 12, value: t('DELIVERY_FAILED_BY_DRIVER', theme?.defaultLanguages?.DELIVERY_FAILED_BY_DRIVER || 'Delivery Failed by driver') },
|
|
59
|
-
{ key: 13, value: t('PREORDER', theme?.defaultLanguages?.PREORDER || 'PreOrder') },
|
|
60
|
-
{ key: 14, value: t('ORDER_NOT_READY', theme?.defaultLanguages?.ORDER_NOT_READY || 'Order not ready') },
|
|
61
|
-
{ key: 15, value: t('ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER', theme?.defaultLanguages?.ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER || 'Order picked up completed by customer') },
|
|
62
|
-
{ key: 16, value: t('ORDER_STATUS_CANCELLED_BY_CUSTOMER', theme?.defaultLanguages?.ORDER_STATUS_CANCELLED_BY_CUSTOMER || 'Order cancelled by customer') },
|
|
63
|
-
{ key: 17, value: t('ORDER_NOT_PICKEDUP_BY_CUSTOMER', theme?.defaultLanguages?.ORDER_NOT_PICKEDUP_BY_CUSTOMER || 'Order not picked up by customer') },
|
|
64
|
-
{ key: 18, value: t('ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS', theme?.defaultLanguages?.ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS || 'Driver almost arrived to business') },
|
|
65
|
-
{ key: 19, value: t('ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER', theme?.defaultLanguages?.ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER || 'Driver almost arrived to customer') },
|
|
66
|
-
{ key: 20, value: t('ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS', theme?.defaultLanguages?.ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS || 'Customer almost arrived to business') },
|
|
67
|
-
{ key: 21, value: t('ORDER_CUSTOMER_ARRIVED_BUSINESS', theme?.defaultLanguages?.ORDER_CUSTOMER_ARRIVED_BUSINESS || 'Customer arrived to business') },
|
|
68
|
-
{ key: 22, value: t('ORDER_LOOKING_FOR_DRIVER', theme?.defaultLanguages?.ORDER_LOOKING_FOR_DRIVER || 'Looking for driver') },
|
|
69
|
-
{ key: 23, value: t('ORDER_DRIVER_ON_WAY', theme?.defaultLanguages?.ORDER_DRIVER_ON_WAY || 'Driver on way') }
|
|
70
|
-
]
|
|
71
|
-
|
|
72
|
-
const objectStatus = orderStatus.find((o) => o.key === status)
|
|
73
|
-
|
|
74
|
-
return objectStatus && objectStatus
|
|
75
|
-
}
|
|
76
|
-
|
|
77
43
|
const onProductClick = (product: any) => {
|
|
78
44
|
const categoryId = product?.category?.id
|
|
79
45
|
const businessId = product?.category?.business?.id
|
|
@@ -6,6 +6,7 @@ import { NotFoundSource } from '../NotFoundSource'
|
|
|
6
6
|
|
|
7
7
|
import { ItemWrap } from './styles'
|
|
8
8
|
import { OrdersOptionParams } from '../../types'
|
|
9
|
+
import { getOrderStatus } from '../../utils'
|
|
9
10
|
|
|
10
11
|
import {
|
|
11
12
|
Placeholder,
|
|
@@ -67,40 +68,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
67
68
|
return moment(dateStr).format('MMMM DD,YYYY - hh:mm a');
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
const getOrderStatus = (s: string) => {
|
|
71
|
-
const status = parseInt(s)
|
|
72
|
-
const orderStatus = [
|
|
73
|
-
{ key: 0, value: t('PENDING', 'Pending') },
|
|
74
|
-
{ key: 1, value: t('COMPLETED', 'Completed') },
|
|
75
|
-
{ key: 2, value: t('REJECTED', 'Rejected') },
|
|
76
|
-
{ key: 3, value: t('DRIVER_IN_BUSINESS', 'Driver in business') },
|
|
77
|
-
{ key: 4, value: t('PREPARATION_COMPLETED', 'Preparation Completed') },
|
|
78
|
-
{ key: 5, value: t('REJECTED_BY_BUSINESS', 'Rejected by business') },
|
|
79
|
-
{ key: 6, value: t('REJECTED_BY_DRIVER', 'Rejected by Driver') },
|
|
80
|
-
{ key: 7, value: t('ACCEPTED_BY_BUSINESS', 'Accepted by business') },
|
|
81
|
-
{ key: 8, value: t('ACCEPTED_BY_DRIVER', 'Accepted by driver') },
|
|
82
|
-
{ key: 9, value: t('PICK_UP_COMPLETED_BY_DRIVER', 'Pick up completed by driver') },
|
|
83
|
-
{ key: 10, value: t('PICK_UP_FAILED_BY_DRIVER', 'Pick up Failed by driver') },
|
|
84
|
-
{ key: 11, value: t('DELIVERY_COMPLETED_BY_DRIVER', 'Delivery completed by driver') },
|
|
85
|
-
{ key: 12, value: t('DELIVERY_FAILED_BY_DRIVER', 'Delivery Failed by driver') },
|
|
86
|
-
{ key: 13, value: t('PREORDER', 'PreOrder') },
|
|
87
|
-
{ key: 14, value: t('ORDER_NOT_READY', 'Order not ready') },
|
|
88
|
-
{ key: 15, value: t('ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER', 'Order picked up completed by customer') },
|
|
89
|
-
{ key: 16, value: t('CANCELLED_BY_CUSTOMER', 'Cancelled by customer') },
|
|
90
|
-
{ key: 17, value: t('ORDER_NOT_PICKEDUP_BY_CUSTOMER', 'Order not picked up by customer') },
|
|
91
|
-
{ key: 18, value: t('DRIVER_ALMOST_ARRIVED_TO_BUSINESS', 'Driver almost arrived to business') },
|
|
92
|
-
{ key: 19, value: t('DRIVER_ALMOST_ARRIVED_TO_CUSTOMER', 'Driver almost arrived to customer') },
|
|
93
|
-
{ key: 20, value: t('ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS', 'Customer almost arrived to business') },
|
|
94
|
-
{ key: 21, value: t('ORDER_CUSTOMER_ARRIVED_BUSINESS', 'Customer arrived to business') },
|
|
95
|
-
{ key: 22, value: t('ORDER_LOOKING_FOR_DRIVER', 'Looking for driver') },
|
|
96
|
-
{ key: 23, value: t('ORDER_DRIVER_ON_WAY', 'Driver on way') }
|
|
97
|
-
]
|
|
98
|
-
|
|
99
|
-
const objectStatus = orderStatus.find((o) => o.key === status)
|
|
100
|
-
|
|
101
|
-
return objectStatus && objectStatus
|
|
102
|
-
}
|
|
103
|
-
|
|
104
71
|
return (
|
|
105
72
|
<>
|
|
106
73
|
{/* {(orders.length > 0) && (
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
MessageListingWrapper,
|
|
22
22
|
MessageContainer
|
|
23
23
|
} from './styles';
|
|
24
|
+
import { getOrderStatus } from '../../utils'
|
|
24
25
|
|
|
25
26
|
const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
26
27
|
const {
|
|
@@ -51,40 +52,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
|
|
|
51
52
|
: theme.images.general.emptyPastOrders
|
|
52
53
|
const orders = customArray || values || []
|
|
53
54
|
|
|
54
|
-
const getOrderStatus = (s: string) => {
|
|
55
|
-
const status = parseInt(s)
|
|
56
|
-
const orderStatus = [
|
|
57
|
-
{ key: 0, value: t('PENDING', 'Pending') },
|
|
58
|
-
{ key: 1, value: t('COMPLETED', 'Completed') },
|
|
59
|
-
{ key: 2, value: t('REJECTED', 'Rejected') },
|
|
60
|
-
{ key: 3, value: t('DRIVER_IN_BUSINESS', 'Driver in business') },
|
|
61
|
-
{ key: 4, value: t('PREPARATION_COMPLETED', 'Preparation Completed') },
|
|
62
|
-
{ key: 5, value: t('REJECTED_BY_BUSINESS', 'Rejected by business') },
|
|
63
|
-
{ key: 6, value: t('REJECTED_BY_DRIVER', 'Rejected by Driver') },
|
|
64
|
-
{ key: 7, value: t('ACCEPTED_BY_BUSINESS', 'Accepted by business') },
|
|
65
|
-
{ key: 8, value: t('ACCEPTED_BY_DRIVER', 'Accepted by driver') },
|
|
66
|
-
{ key: 9, value: t('PICK_UP_COMPLETED_BY_DRIVER', 'Pick up completed by driver') },
|
|
67
|
-
{ key: 10, value: t('PICK_UP_FAILED_BY_DRIVER', 'Pick up Failed by driver') },
|
|
68
|
-
{ key: 11, value: t('DELIVERY_COMPLETED_BY_DRIVER', 'Delivery completed by driver') },
|
|
69
|
-
{ key: 12, value: t('DELIVERY_FAILED_BY_DRIVER', 'Delivery Failed by driver') },
|
|
70
|
-
{ key: 13, value: t('PREORDER', 'PreOrder') },
|
|
71
|
-
{ key: 14, value: t('ORDER_NOT_READY', 'Order not ready') },
|
|
72
|
-
{ key: 15, value: t('ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER', 'Order picked up completed by customer') },
|
|
73
|
-
{ key: 16, value: t('CANCELLED_BY_CUSTOMER', 'Cancelled by customer') },
|
|
74
|
-
{ key: 17, value: t('ORDER_NOT_PICKEDUP_BY_CUSTOMER', 'Order not picked up by customer') },
|
|
75
|
-
{ key: 18, value: t('DRIVER_ALMOST_ARRIVED_TO_BUSINESS', 'Driver almost arrived to business') },
|
|
76
|
-
{ key: 19, value: t('DRIVER_ALMOST_ARRIVED_TO_CUSTOMER', 'Driver almost arrived to customer') },
|
|
77
|
-
{ key: 20, value: t('ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS', 'Customer almost arrived to business') },
|
|
78
|
-
{ key: 21, value: t('ORDER_CUSTOMER_ARRIVED_BUSINESS', 'Customer arrived to business') },
|
|
79
|
-
{ key: 22, value: t('ORDER_LOOKING_FOR_DRIVER', 'Looking for driver') },
|
|
80
|
-
{ key: 23, value: t('ORDER_DRIVER_ON_WAY', 'Driver on way') }
|
|
81
|
-
]
|
|
82
|
-
|
|
83
|
-
const objectStatus = orderStatus.find((o) => o.key === status)
|
|
84
|
-
|
|
85
|
-
return objectStatus && objectStatus
|
|
86
|
-
}
|
|
87
|
-
|
|
88
55
|
const handleClickOrder = (uuid: string) => {
|
|
89
56
|
setSelectedOrderId(uuid)
|
|
90
57
|
setOpenMessges(true)
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
useValidationFields,
|
|
8
8
|
useSession,
|
|
9
9
|
useToast,
|
|
10
|
-
|
|
10
|
+
ToastType,
|
|
11
11
|
MultiCheckout as MultiCheckoutController
|
|
12
12
|
} from 'ordering-components/native'
|
|
13
13
|
import { View, StyleSheet, Platform } from 'react-native'
|
|
@@ -36,11 +36,11 @@ import {
|
|
|
36
36
|
} from './styles'
|
|
37
37
|
|
|
38
38
|
const mapConfigs = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
mapZoom: 16,
|
|
40
|
+
mapSize: {
|
|
41
|
+
width: 640,
|
|
42
|
+
height: 190
|
|
43
|
+
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const MultiCheckoutUI = (props: any) => {
|
|
@@ -54,75 +54,77 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
54
54
|
handleSelectPaymethod,
|
|
55
55
|
handleSelectWallet,
|
|
56
56
|
handlePaymethodDataChange,
|
|
57
|
-
cartUuid
|
|
57
|
+
cartUuid,
|
|
58
|
+
totalCartsFee,
|
|
59
|
+
cartGroup
|
|
58
60
|
} = props
|
|
59
61
|
|
|
60
|
-
|
|
62
|
+
const theme = useTheme();
|
|
61
63
|
const styles = StyleSheet.create({
|
|
62
64
|
pagePadding: {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
paddingLeft: 40,
|
|
66
|
+
paddingRight: 40
|
|
67
|
+
},
|
|
66
68
|
wrapperNavbar: Platform.OS === 'ios'
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
? { paddingVertical: 0, paddingHorizontal: 40 }
|
|
70
|
+
: { paddingVertical: 20, paddingHorizontal: 40 }
|
|
69
71
|
})
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
const [, { showToast }] = useToast();
|
|
72
74
|
const [, t] = useLanguage()
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
const [{ configs }] = useConfig();
|
|
76
|
+
const [{ parsePrice, parseDate }] = useUtils();
|
|
77
|
+
const [{ options, carts, loading }, { confirmCart }] = useOrder();
|
|
78
|
+
const [validationFields] = useValidationFields();
|
|
77
79
|
const [{ user }] = useSession()
|
|
78
80
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
const configTypes = configs?.order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
|
|
82
|
+
const isPreOrder = configs?.preorder_status_enabled?.value === '1'
|
|
81
83
|
const maximumCarts = 5
|
|
82
84
|
const isDisablePlaceOrderButton = !(paymethodSelected?.paymethod_id || paymethodSelected?.wallet_id) || openCarts.length > maximumCarts || (paymethodSelected?.paymethod?.gateway === 'stripe' && !paymethodSelected?.paymethod_data)
|
|
83
85
|
const walletCarts = (Object.values(carts)?.filter((cart: any) => cart?.products && cart?.products?.length && cart?.status !== 2 && cart?.valid_schedule && cart?.valid_products && cart?.valid_address && cart?.valid_maximum && cart?.valid_minimum && cart?.wallets) || null) || []
|
|
84
86
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
const [isUserDetailsEdit, setIsUserDetailsEdit] = useState(false);
|
|
88
|
+
const [phoneUpdate, setPhoneUpdate] = useState(false);
|
|
89
|
+
const [userErrors, setUserErrors] = useState<any>([]);
|
|
88
90
|
const handleMomentClick = () => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
if (isPreOrder) {
|
|
92
|
+
navigation.navigate('MomentOption')
|
|
93
|
+
}
|
|
94
|
+
}
|
|
93
95
|
|
|
94
96
|
const checkValidationFields = () => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
setUserErrors([])
|
|
98
|
+
const errors = []
|
|
99
|
+
const notFields = ['coupon', 'driver_tip', 'mobile_phone', 'address', 'zipcode', 'address_notes']
|
|
98
100
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
Object.values(validationFields?.fields?.checkout).map((field: any) => {
|
|
102
|
+
if (field?.required && !notFields.includes(field.code)) {
|
|
103
|
+
if (!user[field?.code]) {
|
|
104
|
+
errors.push(t(`VALIDATION_ERROR_${field.code.toUpperCase()}_REQUIRED`, `The field ${field?.name} is required`))
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
})
|
|
106
108
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
if (
|
|
110
|
+
!user?.cellphone &&
|
|
111
|
+
((validationFields?.fields?.checkout?.cellphone?.enabled &&
|
|
112
|
+
validationFields?.fields?.checkout?.cellphone?.required) ||
|
|
113
|
+
configs?.verification_phone_required?.value === '1')
|
|
114
|
+
) {
|
|
115
|
+
errors.push(t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Phone number is required'))
|
|
116
|
+
}
|
|
115
117
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
if (phoneUpdate) {
|
|
119
|
+
errors.push(t('NECESSARY_UPDATE_COUNTRY_PHONE_CODE', 'It is necessary to update your phone number'))
|
|
120
|
+
}
|
|
119
121
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
setUserErrors(errors)
|
|
123
|
+
}
|
|
122
124
|
|
|
123
125
|
const togglePhoneUpdate = (val: boolean) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
setPhoneUpdate(val)
|
|
127
|
+
}
|
|
126
128
|
|
|
127
129
|
const handlePlaceOrder = () => {
|
|
128
130
|
if (!userErrors.length) {
|
|
@@ -130,18 +132,18 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
130
132
|
return
|
|
131
133
|
}
|
|
132
134
|
let stringError = ''
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
Object.values(userErrors).map((item: any, i: number) => {
|
|
136
|
+
stringError += (i + 1) === userErrors.length ? `- ${item?.message || item}` : `- ${item?.message || item}\n`
|
|
137
|
+
})
|
|
138
|
+
showToast(ToastType.Error, stringError)
|
|
137
139
|
setIsUserDetailsEdit(true)
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
useEffect(() => {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
if (validationFields && validationFields?.fields?.checkout) {
|
|
144
|
+
checkValidationFields()
|
|
145
|
+
}
|
|
146
|
+
}, [validationFields, user])
|
|
145
147
|
|
|
146
148
|
return (
|
|
147
149
|
<>
|
|
@@ -244,12 +246,14 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
244
246
|
cart={cart}
|
|
245
247
|
cartuuid={cart.uuid}
|
|
246
248
|
isMultiCheckout
|
|
249
|
+
hideDeliveryFee={configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1'}
|
|
250
|
+
hideDriverTip={configs?.multi_business_checkout_show_combined_driver_tip?.value === '1'}
|
|
247
251
|
onNavigationRedirect={(route: string, params: any) => props.navigation.navigate(route, params)}
|
|
248
252
|
/>
|
|
249
253
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
|
|
250
254
|
</React.Fragment>
|
|
251
255
|
))}
|
|
252
|
-
{openCarts.length === 0 && (
|
|
256
|
+
{!cartGroup?.loading && openCarts.length === 0 && (
|
|
253
257
|
<CCNotCarts>
|
|
254
258
|
<OText size={24} style={{ textAlign: 'center' }}>
|
|
255
259
|
{t('CARTS_NOT_FOUND', 'You don\'t have carts available')}
|
|
@@ -263,6 +267,25 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
263
267
|
)}
|
|
264
268
|
{openCarts.length > 0 && (
|
|
265
269
|
<ChCartsTotal>
|
|
270
|
+
{totalCartsFee && configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1' && (
|
|
271
|
+
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
272
|
+
<OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
|
|
273
|
+
{t('TOTAL_DELIVERY_FEE', 'Total delivery fee')}
|
|
274
|
+
</OText>
|
|
275
|
+
<OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>{parsePrice(totalCartsFee)}</OText>
|
|
276
|
+
</View>
|
|
277
|
+
)}
|
|
278
|
+
{openCarts.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0) > 0 &&
|
|
279
|
+
configs?.multi_business_checkout_show_combined_driver_tip?.value === '1' && (
|
|
280
|
+
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
281
|
+
<OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
|
|
282
|
+
{t('DRIVER_TIP', 'Driver tip')}
|
|
283
|
+
</OText>
|
|
284
|
+
<OText size={14} lineHeight={24} color={theme.colors.textNormal} weight={'400'}>
|
|
285
|
+
{parsePrice(openCarts.reduce((sum: any, cart: any) => sum + cart?.driver_tip, 0))}
|
|
286
|
+
</OText>
|
|
287
|
+
</View>
|
|
288
|
+
)}
|
|
266
289
|
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
267
290
|
<OText size={16} lineHeight={24} color={theme.colors.textNormal} weight={'500'}>
|
|
268
291
|
{t('TOTAL_FOR_ALL_CARTS', 'Total for all Carts')}
|
|
@@ -283,14 +306,14 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
283
306
|
</ChSection>
|
|
284
307
|
</ChContainer>
|
|
285
308
|
</Container>
|
|
286
|
-
|
|
309
|
+
|
|
287
310
|
<FloatingButton
|
|
288
|
-
|
|
311
|
+
handleClick={() => handlePlaceOrder()}
|
|
289
312
|
isSecondaryBtn={isDisablePlaceOrderButton}
|
|
290
313
|
disabled={isDisablePlaceOrderButton}
|
|
291
314
|
btnText={placing ? t('PLACING', 'Placing') : t('PLACE_ORDER', 'Place Order')}
|
|
292
315
|
btnRightValueShow
|
|
293
|
-
|
|
316
|
+
btnRightValue={parsePrice(totalCartsPrice)}
|
|
294
317
|
iosBottom={30}
|
|
295
318
|
/>
|
|
296
319
|
</>
|