ordering-ui-react-native 0.17.92 → 0.17.94
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/BusinessProductsListing/index.tsx +530 -527
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +1 -1
- package/themes/original/src/components/Cart/index.tsx +43 -5
- package/themes/original/src/components/CartContent/index.tsx +33 -29
- package/themes/original/src/components/Checkout/index.tsx +12 -1
- package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +2 -2
- package/themes/original/src/components/MomentOption/index.tsx +159 -63
- package/themes/original/src/components/MomentOption/styles.tsx +15 -0
- package/themes/original/src/components/MultiCheckout/index.tsx +27 -1
- package/themes/original/src/components/OrderSummary/index.tsx +24 -1
- package/themes/original/src/config/constants.tsx +10 -0
- package/themes/original/src/types/index.tsx +9 -1
|
@@ -160,7 +160,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
160
160
|
const [featuredBusiness, setFeaturedBusinesses] = useState(Array);
|
|
161
161
|
const [isFarAway, setIsFarAway] = useState(false)
|
|
162
162
|
const [businessTypes, setBusinessTypes] = useState(null)
|
|
163
|
-
const [orderTypeValue, setOrderTypeValue] = useState(orderState?.options
|
|
163
|
+
const [orderTypeValue, setOrderTypeValue] = useState(orderState?.options?.value)
|
|
164
164
|
const [isOpenCities, setIsOpenCities] = useState(false)
|
|
165
165
|
const isPreorderEnabled = (configs?.preorder_status_enabled?.value === '1' || configs?.preorder_status_enabled?.value === 'true') &&
|
|
166
166
|
Number(configs?.max_days_preorder?.value) > 0
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Cart as CartController,
|
|
4
4
|
useOrder,
|
|
@@ -26,6 +26,7 @@ import { CartStoresListing } from '../CartStoresListing';
|
|
|
26
26
|
import { OAlert } from '../../../../../src/components/shared'
|
|
27
27
|
import { PlaceSpot } from '../PlaceSpot'
|
|
28
28
|
import { DriverTips } from '../DriverTips'
|
|
29
|
+
import { MomentOption } from '../MomentOption'
|
|
29
30
|
|
|
30
31
|
const CartUI = (props: any) => {
|
|
31
32
|
const {
|
|
@@ -43,7 +44,13 @@ const CartUI = (props: any) => {
|
|
|
43
44
|
handleRemoveOfferClick,
|
|
44
45
|
isMultiCheckout,
|
|
45
46
|
hideDeliveryFee,
|
|
46
|
-
hideDriverTip
|
|
47
|
+
hideDriverTip,
|
|
48
|
+
preorderSlotInterval,
|
|
49
|
+
preorderLeadTime,
|
|
50
|
+
preorderTimeRange,
|
|
51
|
+
preorderMaximumDays,
|
|
52
|
+
preorderMinimumDays,
|
|
53
|
+
cateringTypes
|
|
47
54
|
} = props
|
|
48
55
|
|
|
49
56
|
const theme = useTheme();
|
|
@@ -60,7 +67,7 @@ const CartUI = (props: any) => {
|
|
|
60
67
|
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null, type: '' })
|
|
61
68
|
const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
|
|
62
69
|
const [openPlaceModal, setOpenPlaceModal] = useState(false)
|
|
63
|
-
|
|
70
|
+
const [maxDate, setMaxDate] = useState<any>(null)
|
|
64
71
|
const isCartPending = cart?.status === 2
|
|
65
72
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
|
|
66
73
|
const business: any = (orderState?.carts && Object.values(orderState.carts).find((_cart: any) => _cart?.uuid === props.cartuuid)) ?? {}
|
|
@@ -125,7 +132,10 @@ const CartUI = (props: any) => {
|
|
|
125
132
|
(Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
|
|
126
133
|
Object.keys(groupKeys).length > 1
|
|
127
134
|
) {
|
|
128
|
-
onNavigationRedirect('CheckoutNavigator', {
|
|
135
|
+
onNavigationRedirect('CheckoutNavigator', {
|
|
136
|
+
screen: 'MultiCheckout',
|
|
137
|
+
checkCarts: true
|
|
138
|
+
})
|
|
129
139
|
} else {
|
|
130
140
|
onNavigationRedirect('CheckoutNavigator', {
|
|
131
141
|
screen: 'MultiCheckout',
|
|
@@ -176,6 +186,19 @@ const CartUI = (props: any) => {
|
|
|
176
186
|
return acc = acc
|
|
177
187
|
}, cart?.subtotal)
|
|
178
188
|
|
|
189
|
+
useEffect(() => {
|
|
190
|
+
const limitDays = parseInt(preorderMaximumDays ?? configs?.max_days_preorder?.value, 10)
|
|
191
|
+
const currentDate = new Date()
|
|
192
|
+
const time = limitDays > 1
|
|
193
|
+
? currentDate.getTime() + ((limitDays - 1) * 24 * 60 * 60 * 1000)
|
|
194
|
+
: limitDays === 1 ? currentDate.getTime() : currentDate.getTime() + (6 * 24 * 60 * 60 * 1000)
|
|
195
|
+
|
|
196
|
+
currentDate.setTime(time)
|
|
197
|
+
currentDate.setHours(23)
|
|
198
|
+
currentDate.setMinutes(59)
|
|
199
|
+
setMaxDate(currentDate)
|
|
200
|
+
}, [preorderMaximumDays, configs?.max_days_preorder?.value])
|
|
201
|
+
|
|
179
202
|
return (
|
|
180
203
|
<CContainer>
|
|
181
204
|
{openUpselling && (
|
|
@@ -483,6 +506,21 @@ const CartUI = (props: any) => {
|
|
|
483
506
|
)}
|
|
484
507
|
</OSBill>
|
|
485
508
|
)}
|
|
509
|
+
{cateringTypes.includes(orderState?.options?.type) && maxDate && cart?.valid_products && (
|
|
510
|
+
<View>
|
|
511
|
+
<MomentOption
|
|
512
|
+
maxDate={maxDate}
|
|
513
|
+
cateringPreorder
|
|
514
|
+
isCart
|
|
515
|
+
preorderSlotInterval={preorderSlotInterval}
|
|
516
|
+
preorderLeadTime={preorderLeadTime}
|
|
517
|
+
preorderTimeRange={preorderTimeRange}
|
|
518
|
+
preorderMaximumDays={preorderMaximumDays}
|
|
519
|
+
preorderMinimumDays={preorderMinimumDays}
|
|
520
|
+
business={cart?.business}
|
|
521
|
+
/>
|
|
522
|
+
</View>
|
|
523
|
+
)}
|
|
486
524
|
{!isMultiCheckout && (
|
|
487
525
|
<>
|
|
488
526
|
{cart?.valid_products ? (
|
|
@@ -499,7 +537,7 @@ const CartUI = (props: any) => {
|
|
|
499
537
|
isDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
|
|
500
538
|
borderColor={theme.colors.primary}
|
|
501
539
|
imgRightSrc={null}
|
|
502
|
-
textStyle={{ color: '
|
|
540
|
+
textStyle={{ color: '#fff', textAlign: 'center', flex: 1 }}
|
|
503
541
|
onClick={() => setOpenUpselling(true)}
|
|
504
542
|
style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
|
|
505
543
|
/>
|
|
@@ -20,39 +20,42 @@ export const CartContent = (props: any) => {
|
|
|
20
20
|
const [{ configs }] = useConfig()
|
|
21
21
|
const [isCartsLoading, setIsCartsLoading] = useState(false)
|
|
22
22
|
|
|
23
|
-
const isChewLayout = theme?.header?.components?.layout?.type
|
|
23
|
+
const isChewLayout = theme?.header?.components?.layout?.type === 'chew'
|
|
24
24
|
const isMultiCheckout = configs?.checkout_multi_business_enabled?.value === '1'
|
|
25
25
|
const cartsAvailable: any = Object.values(carts)?.filter((cart: any) => cart?.valid && cart?.status !== 2)
|
|
26
26
|
|
|
27
27
|
const handleCheckoutRedirect = () => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
if (cartsAvailable.length === 1) {
|
|
29
|
+
onNavigationRedirect('CheckoutNavigator', {
|
|
30
|
+
screen: 'CheckoutPage',
|
|
31
|
+
cartUuid: cartsAvailable[0]?.uuid,
|
|
32
|
+
businessLogo: cartsAvailable[0]?.business?.logo,
|
|
33
|
+
businessName: cartsAvailable[0]?.business?.name,
|
|
34
|
+
cartTotal: cartsAvailable[0]?.total
|
|
35
|
+
})
|
|
36
|
+
} else {
|
|
37
|
+
const groupKeys: any = {}
|
|
38
|
+
cartsAvailable.forEach((_cart: any) => {
|
|
39
|
+
groupKeys[_cart?.group?.uuid]
|
|
40
|
+
? groupKeys[_cart?.group?.uuid] += 1
|
|
41
|
+
: groupKeys[_cart?.group?.uuid ?? 'null'] = 1
|
|
42
|
+
})
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
if (
|
|
45
|
+
(Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
|
|
46
|
+
Object.keys(groupKeys).length > 1
|
|
47
|
+
) {
|
|
48
|
+
onNavigationRedirect('CheckoutNavigator', {
|
|
49
|
+
screen: 'MultiCheckout',
|
|
50
|
+
checkCarts: true
|
|
51
|
+
})
|
|
52
|
+
} else {
|
|
53
|
+
onNavigationRedirect('CheckoutNavigator', {
|
|
54
|
+
screen: 'MultiCheckout',
|
|
55
|
+
cartUuid: cartsAvailable[0]?.group?.uuid
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
}
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
return (
|
|
@@ -62,7 +65,7 @@ export const CartContent = (props: any) => {
|
|
|
62
65
|
{isOrderStateCarts && carts?.length > 0 && (
|
|
63
66
|
<>
|
|
64
67
|
{carts.map((cart: any, i: number) => (
|
|
65
|
-
<CCList key={i} style={{ overflow: 'visible' }}>
|
|
68
|
+
<CCList nestedScrollEnabled={true} key={i} style={{ overflow: 'visible' }}>
|
|
66
69
|
{cart.products.length > 0 && (
|
|
67
70
|
<>
|
|
68
71
|
<Cart
|
|
@@ -75,6 +78,7 @@ export const CartContent = (props: any) => {
|
|
|
75
78
|
setIsCartsLoading={setIsCartsLoading}
|
|
76
79
|
isMultiCheckout={isMultiCheckout}
|
|
77
80
|
hideUpselling
|
|
81
|
+
businessConfigs={cart?.business?.configs}
|
|
78
82
|
/>
|
|
79
83
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40, marginTop: 20 }} />
|
|
80
84
|
</>
|
|
@@ -88,7 +88,8 @@ const CheckoutUI = (props: any) => {
|
|
|
88
88
|
handleChangeDeliveryOption,
|
|
89
89
|
currency,
|
|
90
90
|
merchantId,
|
|
91
|
-
setPlaceSpotNumber
|
|
91
|
+
setPlaceSpotNumber,
|
|
92
|
+
maxDate
|
|
92
93
|
} = props
|
|
93
94
|
|
|
94
95
|
const theme = useTheme();
|
|
@@ -675,6 +676,8 @@ const CheckoutUI = (props: any) => {
|
|
|
675
676
|
isCartPending={cart?.status === 2}
|
|
676
677
|
onNavigationRedirect={onNavigationRedirect}
|
|
677
678
|
placeSpotTypes={placeSpotTypes}
|
|
679
|
+
businessConfigs={businessConfigs}
|
|
680
|
+
maxDate={maxDate}
|
|
678
681
|
/>
|
|
679
682
|
</>
|
|
680
683
|
)}
|
|
@@ -711,6 +714,14 @@ const CheckoutUI = (props: any) => {
|
|
|
711
714
|
{t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
|
|
712
715
|
</OText>
|
|
713
716
|
)}
|
|
717
|
+
{!cart?.valid_preorder && (
|
|
718
|
+
<OText
|
|
719
|
+
color={theme.colors.error}
|
|
720
|
+
size={12}
|
|
721
|
+
>
|
|
722
|
+
{t('INVALID_CART_MOMENT', 'Selected schedule time is invalid, please select a schedule into the business schedule interval.')}
|
|
723
|
+
</OText>
|
|
724
|
+
)}
|
|
714
725
|
{options.type === 1 &&
|
|
715
726
|
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
716
727
|
validationFields?.fields?.checkout?.driver_tip?.required &&
|
|
@@ -148,8 +148,8 @@ const RedeemGiftCardUI = (props: any) => {
|
|
|
148
148
|
<OText color={theme.colors.textNormal} size={14} mBottom={6}>{t('TYPE', 'Type')}: {redeemedGiftCard?.type}</OText>
|
|
149
149
|
<OText color={theme.colors.textNormal} size={14} mBottom={6}>{t('AMOUNT', 'Amount')}: {parsePrice(redeemedGiftCard?.amount)}</OText>
|
|
150
150
|
<OText color={theme.colors.textNormal} size={14} mBottom={6}>{t('FROM', 'From')}: {redeemedGiftCard?.receiver?.name} {redeemedGiftCard?.receiver?.lastname}</OText>
|
|
151
|
-
<OText color={theme.colors.textNormal} size={14} mBottom={6}>{t('TITLE', 'Title')}: {redeemedGiftCard?.title}</OText>
|
|
152
|
-
<OText color={theme.colors.textNormal} size={14} mBottom={6}>{t('MESSAGES', 'Messages')}: {redeemedGiftCard?.message}</OText>
|
|
151
|
+
{!!redeemedGiftCard?.title && <OText color={theme.colors.textNormal} size={14} mBottom={6}>{t('TITLE', 'Title')}: {redeemedGiftCard?.title}</OText>}
|
|
152
|
+
{!!redeemedGiftCard?.message && <OText color={theme.colors.textNormal} size={14} mBottom={6}>{t('MESSAGES', 'Messages')}: {redeemedGiftCard?.message}</OText>}
|
|
153
153
|
<OButton
|
|
154
154
|
onClick={() => {
|
|
155
155
|
setRedeemedGiftCard(null)
|
|
@@ -13,8 +13,8 @@ import IconAntDesign from 'react-native-vector-icons/AntDesign'
|
|
|
13
13
|
import {
|
|
14
14
|
StyleSheet,
|
|
15
15
|
View,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
Platform,
|
|
17
|
+
Pressable
|
|
18
18
|
} from 'react-native';
|
|
19
19
|
import Spinner from 'react-native-loading-spinner-overlay';
|
|
20
20
|
import { MomentOptionParams } from '../../types';
|
|
@@ -38,6 +38,14 @@ const MomentOptionUI = (props: MomentOptionParams) => {
|
|
|
38
38
|
hoursList,
|
|
39
39
|
dateSelected,
|
|
40
40
|
timeSelected,
|
|
41
|
+
cateringPreorder,
|
|
42
|
+
isCart,
|
|
43
|
+
preorderLeadTime,
|
|
44
|
+
business,
|
|
45
|
+
getActualSchedule,
|
|
46
|
+
preorderMaximumDays,
|
|
47
|
+
preorderMinimumDays,
|
|
48
|
+
isPage,
|
|
41
49
|
handleAsap,
|
|
42
50
|
handleChangeDate,
|
|
43
51
|
handleChangeTime,
|
|
@@ -151,8 +159,8 @@ const MomentOptionUI = (props: MomentOptionParams) => {
|
|
|
151
159
|
|
|
152
160
|
const [selectedTime, setSelectedTime] = useState(null);
|
|
153
161
|
const [datesWhitelist, setDateWhitelist] = useState<any>([{ start: null, end: null }])
|
|
154
|
-
const [selectDate, setSelectedDate] = useState<any>(
|
|
155
|
-
|
|
162
|
+
const [selectDate, setSelectedDate] = useState<any>(dateSelected)
|
|
163
|
+
const [timeList, setTimeList] = useState<any>(hoursList)
|
|
156
164
|
const goToBack = () => navigation?.canGoBack() && navigation.goBack();
|
|
157
165
|
|
|
158
166
|
const _handleAsap = () => {
|
|
@@ -164,9 +172,9 @@ const MomentOptionUI = (props: MomentOptionParams) => {
|
|
|
164
172
|
}
|
|
165
173
|
};
|
|
166
174
|
|
|
167
|
-
const handleChangeMoment = () => {
|
|
175
|
+
const handleChangeMoment = (time?: any) => {
|
|
168
176
|
setMomentState({ isLoading: 1, isEditing: true });
|
|
169
|
-
handleChangeTime(selectedTime);
|
|
177
|
+
handleChangeTime(time ?? selectedTime);
|
|
170
178
|
};
|
|
171
179
|
|
|
172
180
|
const momento = moment(
|
|
@@ -205,6 +213,14 @@ const MomentOptionUI = (props: MomentOptionParams) => {
|
|
|
205
213
|
if (handleChangeDate) handleChangeDate(moment(val).format('YYYY-MM-DD'))
|
|
206
214
|
}
|
|
207
215
|
|
|
216
|
+
const handleChangeTimeSelected = (time: any) => {
|
|
217
|
+
if (cateringPreorder) {
|
|
218
|
+
handleChangeMoment(time)
|
|
219
|
+
} else {
|
|
220
|
+
setSelectedTime(time)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
208
224
|
const LeftSelector = () => {
|
|
209
225
|
return (
|
|
210
226
|
<View style={{ height: '100%', justifyContent: 'flex-end' }}>
|
|
@@ -231,20 +247,25 @@ const MomentOptionUI = (props: MomentOptionParams) => {
|
|
|
231
247
|
|
|
232
248
|
useEffect(() => {
|
|
233
249
|
if (datesList?.length > 0) {
|
|
234
|
-
const _datesList = datesList.slice(0, Number(configs?.max_days_preorder?.value
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
250
|
+
const _datesList = datesList.slice((cateringPreorder && preorderMinimumDays) || 0, Number(cateringPreorder ? preorderMaximumDays || configs?.max_days_preorder?.value : configs?.max_days_preorder?.value ?? 6))
|
|
251
|
+
if (_datesList?.length > 0) {
|
|
252
|
+
const minDateParts = _datesList?.[0]?.split('-')
|
|
253
|
+
const maxDateParts = _datesList[_datesList.length - 1].split('-')
|
|
254
|
+
const _minDate = new Date(minDateParts[0], minDateParts[1] - 1, minDateParts[2])
|
|
255
|
+
const _maxDate = new Date(maxDateParts[0], maxDateParts[1] - 1, maxDateParts[2])
|
|
256
|
+
setDateWhitelist([{ start: _minDate, end: _maxDate }])
|
|
257
|
+
}
|
|
240
258
|
}
|
|
241
|
-
}, [datesList])
|
|
259
|
+
}, [JSON.stringify(datesList), preorderMinimumDays, preorderMaximumDays])
|
|
242
260
|
|
|
243
261
|
useEffect(() => {
|
|
244
262
|
if (dateSelected) {
|
|
245
263
|
const dateParts = dateSelected.split('-')
|
|
246
264
|
const _dateSelected = new Date(dateParts[0], dateParts[1] - 1, dateParts[2])
|
|
247
265
|
setSelectedDate(_dateSelected)
|
|
266
|
+
if (cateringPreorder) {
|
|
267
|
+
onSelectDate(_dateSelected)
|
|
268
|
+
}
|
|
248
269
|
}
|
|
249
270
|
}, [dateSelected])
|
|
250
271
|
|
|
@@ -252,42 +273,98 @@ const MomentOptionUI = (props: MomentOptionParams) => {
|
|
|
252
273
|
setSelectedTime(timeSelected)
|
|
253
274
|
}, [timeSelected])
|
|
254
275
|
|
|
276
|
+
useEffect(() => {
|
|
277
|
+
if (cateringPreorder) {
|
|
278
|
+
let _timeLists = []
|
|
279
|
+
const schedule = business && getActualSchedule()
|
|
280
|
+
if (!schedule && business) {
|
|
281
|
+
return
|
|
282
|
+
}
|
|
283
|
+
_timeLists = hoursList
|
|
284
|
+
.filter(hour => (!business || schedule?.lapses?.some((lapse: any) =>
|
|
285
|
+
moment(dateSelected + ` ${hour.startTime}`) >= moment(dateSelected + ` ${lapse.open.hour}:${lapse.open.minute}`).add(preorderLeadTime, 'minutes') && moment(dateSelected + ` ${hour.endTime}`) <= moment(dateSelected + ` ${lapse.close.hour}:${lapse.close.minute}`))) &&
|
|
286
|
+
moment(dateSelected + ` ${hour.startTime}`) < moment(dateSelected + ` ${hour.endTime}`) &&
|
|
287
|
+
(moment().add(preorderLeadTime, 'minutes') < moment(dateSelected + ` ${hour.startTime}`) || !cateringPreorder))
|
|
288
|
+
.map(hour => {
|
|
289
|
+
return {
|
|
290
|
+
value: hour.startTime,
|
|
291
|
+
text: is12hours ? (
|
|
292
|
+
hour.startTime.includes('12')
|
|
293
|
+
? `${hour.startTime}PM`
|
|
294
|
+
: parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'hh:mma' })
|
|
295
|
+
) : (
|
|
296
|
+
parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'HH:mm' })
|
|
297
|
+
),
|
|
298
|
+
endText: is12hours ? (
|
|
299
|
+
hour.endTime.includes('12')
|
|
300
|
+
? `${hour.endTime}PM`
|
|
301
|
+
: parseTime(moment(hour.endTime, 'HH:mm'), { outputFormat: 'hh:mma' })
|
|
302
|
+
) : (
|
|
303
|
+
parseTime(moment(hour.endTime, 'HH:mm'), { outputFormat: 'HH:mm' })
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
})
|
|
307
|
+
if (_timeLists?.length > 0) {
|
|
308
|
+
setTimeList(_timeLists)
|
|
309
|
+
}
|
|
310
|
+
} else {
|
|
311
|
+
setTimeList(hoursList.map(hour => {
|
|
312
|
+
return {
|
|
313
|
+
value: hour.startTime,
|
|
314
|
+
text: is12hours ? (
|
|
315
|
+
hour.startTime.includes('12')
|
|
316
|
+
? `${hour.startTime}PM`
|
|
317
|
+
: parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'hh:mma' })
|
|
318
|
+
) : (
|
|
319
|
+
parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'HH:mm' })
|
|
320
|
+
)
|
|
321
|
+
}
|
|
322
|
+
}))
|
|
323
|
+
}
|
|
324
|
+
}, [dateSelected, JSON.stringify(hoursList), JSON.stringify(datesWhitelist), cateringPreorder])
|
|
325
|
+
|
|
255
326
|
return (
|
|
256
327
|
<>
|
|
257
328
|
<Container
|
|
258
329
|
style={{
|
|
259
|
-
paddingLeft: 40,
|
|
260
|
-
paddingRight: 40
|
|
261
|
-
}}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
330
|
+
paddingLeft: !cateringPreorder || isPage ? 40 : 0,
|
|
331
|
+
paddingRight: !cateringPreorder || isPage ? 40 : 0
|
|
332
|
+
}}
|
|
333
|
+
nestedScrollEnabled
|
|
334
|
+
>
|
|
335
|
+
<View style={{ paddingBottom: cateringPreorder ? 0 : 90, paddingRight: 20 }}>
|
|
336
|
+
{!isCart && (
|
|
337
|
+
<NavBar
|
|
338
|
+
onActionLeft={() => goToBack()}
|
|
339
|
+
btnStyle={{ paddingLeft: 0 }}
|
|
340
|
+
style={{ paddingBottom: 0 }}
|
|
341
|
+
paddingTop={Platform.OS === 'ios' ? 10 : 0}
|
|
342
|
+
title={t('QUESTION_WHEN_ORDER', 'When do you want your order?')}
|
|
343
|
+
titleAlign={'center'}
|
|
344
|
+
titleStyle={{ fontSize: 20, marginRight: 0, marginLeft: 0 }}
|
|
345
|
+
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
346
|
+
/>
|
|
347
|
+
)}
|
|
348
|
+
{(preorderMinimumDays === 0 && preorderLeadTime === 0) || !cateringPreorder && (
|
|
349
|
+
<WrapSelectOption
|
|
350
|
+
onPress={() => _handleAsap()}
|
|
351
|
+
disabled={orderState.loading} style={{ alignItems: 'flex-start' }}>
|
|
352
|
+
{optionSelected.isAsap ? (
|
|
353
|
+
<OIcon
|
|
354
|
+
src={theme.images.general.option_checked}
|
|
355
|
+
width={16}
|
|
356
|
+
style={{ marginEnd: 24 }}
|
|
357
|
+
/>
|
|
358
|
+
) : (
|
|
359
|
+
<OIcon
|
|
360
|
+
src={theme.images.general.option_normal}
|
|
361
|
+
width={16}
|
|
362
|
+
style={{ marginEnd: 24 }}
|
|
363
|
+
/>
|
|
364
|
+
)}
|
|
365
|
+
<OText color={optionSelected.isAsap ? theme.colors.textNormal : theme.colors.disabled}>{t('ASAP_ABBREVIATION', 'ASAP') + ` (${t(moment().format('dddd')?.toLocaleUpperCase(), moment().format('dddd'))}, ${t(monthsEnum[moment().format('MMM')], moment().format('MMM'))}${moment().format(' D, yyyy h:mm A')} + ${t('DELIVERY_TIME', 'delivery time')})`}</OText>
|
|
366
|
+
</WrapSelectOption>
|
|
367
|
+
)}
|
|
291
368
|
<WrapSelectOption
|
|
292
369
|
onPress={() => setOptionSelected({ isAsap: false, isSchedule: true })}
|
|
293
370
|
disabled={orderState.loading}>
|
|
@@ -326,8 +403,10 @@ const MomentOptionUI = (props: MomentOptionParams) => {
|
|
|
326
403
|
highlightDateContainerStyle={{ height: '100%' }}
|
|
327
404
|
calendarHeaderFormat='MMMM, YYYY'
|
|
328
405
|
iconStyle={{ borderWidth: 1 }}
|
|
329
|
-
selectedDate={
|
|
406
|
+
selectedDate={dateSelected}
|
|
330
407
|
datesWhitelist={datesWhitelist}
|
|
408
|
+
minDate={moment()}
|
|
409
|
+
maxDate={cateringPreorder ? moment().add(preorderMaximumDays, 'days') : undefined}
|
|
331
410
|
disabledDateNameStyle={styles.disabledDateName}
|
|
332
411
|
disabledDateNumberStyle={styles.disabledDateNumber}
|
|
333
412
|
disabledDateOpacity={0.6}
|
|
@@ -337,27 +416,42 @@ const MomentOptionUI = (props: MomentOptionParams) => {
|
|
|
337
416
|
/>
|
|
338
417
|
)}
|
|
339
418
|
</View>
|
|
340
|
-
<TimeListWrapper nestedScrollEnabled={true}>
|
|
419
|
+
<TimeListWrapper nestedScrollEnabled={true} cateringPreorder={cateringPreorder}>
|
|
341
420
|
<TimeContentWrapper>
|
|
342
|
-
{
|
|
343
|
-
<
|
|
344
|
-
<TimeItem
|
|
421
|
+
{timeList.map((time: any, i: number) => (
|
|
422
|
+
<Pressable key={i} onPress={() => handleChangeTimeSelected(time.value)}>
|
|
423
|
+
<TimeItem
|
|
424
|
+
active={selectedTime === time.value}
|
|
425
|
+
cateringPreorder={cateringPreorder}
|
|
426
|
+
>
|
|
427
|
+
{cateringPreorder && (
|
|
428
|
+
<>
|
|
429
|
+
{selectedTime === time.value ? (
|
|
430
|
+
<OIcon
|
|
431
|
+
src={theme.images.general.option_checked}
|
|
432
|
+
width={18}
|
|
433
|
+
style={{ marginEnd: 24, bottom: 2 }}
|
|
434
|
+
/>
|
|
435
|
+
) : (
|
|
436
|
+
<OIcon
|
|
437
|
+
src={theme.images.general.option_normal}
|
|
438
|
+
width={18}
|
|
439
|
+
style={{ marginEnd: 24, bottom: 2 }}
|
|
440
|
+
/>
|
|
441
|
+
)}
|
|
442
|
+
</>
|
|
443
|
+
)}
|
|
345
444
|
<OText
|
|
346
|
-
size={
|
|
347
|
-
color={selectedTime === time.
|
|
445
|
+
size={cateringPreorder ? 18 : 16}
|
|
446
|
+
color={selectedTime === time.value ? theme.colors.primary : theme.colors.textNormal}
|
|
348
447
|
style={{
|
|
349
448
|
lineHeight: 24
|
|
350
449
|
}}
|
|
351
|
-
>{
|
|
352
|
-
time.startTime.includes('12')
|
|
353
|
-
? `${time.startTime}PM`
|
|
354
|
-
: parseTime(moment(time.startTime, 'HH:mm'), { outputFormat: 'hh:mma' })
|
|
355
|
-
) : time.startTime
|
|
356
|
-
}</OText>
|
|
450
|
+
>{time.text} {cateringPreorder && `- ${time.endText}`}</OText>
|
|
357
451
|
</TimeItem>
|
|
358
|
-
</
|
|
452
|
+
</Pressable>
|
|
359
453
|
))}
|
|
360
|
-
{
|
|
454
|
+
{timeList.length % 3 === 2 && (
|
|
361
455
|
<TimeItem style={{ backgroundColor: 'transparent' }} />
|
|
362
456
|
)}
|
|
363
457
|
</TimeContentWrapper>
|
|
@@ -367,9 +461,11 @@ const MomentOptionUI = (props: MomentOptionParams) => {
|
|
|
367
461
|
</View>
|
|
368
462
|
<Spinner visible={momentState.isLoading === 1} />
|
|
369
463
|
</Container>
|
|
370
|
-
|
|
371
|
-
<
|
|
372
|
-
|
|
464
|
+
{!isCart && (
|
|
465
|
+
<View style={{ position: 'absolute', bottom: bottom, paddingBottom: 20, paddingHorizontal: 40, backgroundColor: 'white', width: '100%' }}>
|
|
466
|
+
<OButton onClick={handleChangeMoment} isDisabled={!selectedTime} text={t('CONTINUE', 'Continue')} style={{ borderRadius: 7.6, height: 44, shadowOpacity: 0 }} textStyle={{ color: 'white', fontSize: 14 }} showNextIcon />
|
|
467
|
+
</View>
|
|
468
|
+
)}
|
|
373
469
|
</>
|
|
374
470
|
);
|
|
375
471
|
};
|
|
@@ -19,6 +19,10 @@ export const OrderTimeWrapper = styled.View`
|
|
|
19
19
|
export const TimeListWrapper = styled.ScrollView`
|
|
20
20
|
margin-top: 30px;
|
|
21
21
|
max-height: 210px;
|
|
22
|
+
${({ cateringPreorder }: any) => cateringPreorder && css`
|
|
23
|
+
max-height: 250px;
|
|
24
|
+
height: 250px;
|
|
25
|
+
`}
|
|
22
26
|
`
|
|
23
27
|
|
|
24
28
|
export const TimeContentWrapper = styled.View`
|
|
@@ -26,6 +30,7 @@ export const TimeContentWrapper = styled.View`
|
|
|
26
30
|
flex-wrap: wrap;
|
|
27
31
|
flex-direction: row;
|
|
28
32
|
justify-content: space-between;
|
|
33
|
+
|
|
29
34
|
`
|
|
30
35
|
|
|
31
36
|
export const TimeItem = styled.View`
|
|
@@ -36,6 +41,16 @@ export const TimeItem = styled.View`
|
|
|
36
41
|
justify-content: center;
|
|
37
42
|
align-items: center;
|
|
38
43
|
margin: 10px 0px;
|
|
44
|
+
${({ cateringPreorder }: any) => cateringPreorder && css`
|
|
45
|
+
background: #fff;
|
|
46
|
+
width: 100%;
|
|
47
|
+
min-width: 100%;
|
|
48
|
+
height: 50px;
|
|
49
|
+
flex-direction: row;
|
|
50
|
+
justify-content: flex-start;
|
|
51
|
+
padding-left: 10px;
|
|
52
|
+
margin: 0;
|
|
53
|
+
`}
|
|
39
54
|
${({ active }: any) => active && css`
|
|
40
55
|
background: #F5F9FF;
|
|
41
56
|
`}
|
|
@@ -18,6 +18,7 @@ import { OText, OIcon, OModal } from '../shared';
|
|
|
18
18
|
import { getTypesText } from '../../utils';
|
|
19
19
|
import { UserDetails } from '../UserDetails'
|
|
20
20
|
import { AddressDetails } from '../AddressDetails'
|
|
21
|
+
import { MultiCart as MultiCartController } from '../MultiCart'
|
|
21
22
|
import { MultiCartsPaymethodsAndWallets } from '../MultiCartsPaymethodsAndWallets'
|
|
22
23
|
import { Cart } from '../Cart'
|
|
23
24
|
import { FloatingButton } from '../FloatingButton'
|
|
@@ -345,9 +346,34 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
345
346
|
}
|
|
346
347
|
|
|
347
348
|
export const MultiCheckout = (props: any) => {
|
|
349
|
+
const [loadMultiCarts, setLoadMultiCarts] = useState(!!props.route?.params?.checkCarts)
|
|
350
|
+
const [cartUuid, setCartUuid] = useState('')
|
|
351
|
+
|
|
348
352
|
const multiCheckoutProps = {
|
|
349
353
|
...props,
|
|
354
|
+
cartUuid: props.route?.params?.cartUuid ?? cartUuid,
|
|
350
355
|
UIComponent: MultiCheckoutUI
|
|
351
356
|
}
|
|
352
|
-
|
|
357
|
+
|
|
358
|
+
const multiCartProps = {
|
|
359
|
+
...props,
|
|
360
|
+
handleOnRedirectMultiCheckout: (cartUuid: string) => {
|
|
361
|
+
setCartUuid(cartUuid)
|
|
362
|
+
setLoadMultiCarts(false)
|
|
363
|
+
},
|
|
364
|
+
handleOnRedirectCheckout: (cartUuid: string) => {
|
|
365
|
+
props.navigation.navigate('CheckoutNavigator', {
|
|
366
|
+
screen: 'CheckoutPage',
|
|
367
|
+
cartUuid: cartUuid
|
|
368
|
+
})
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return (
|
|
373
|
+
loadMultiCarts ? (
|
|
374
|
+
<MultiCartController {...multiCartProps} />
|
|
375
|
+
) : (
|
|
376
|
+
<MultiCheckoutController {...multiCheckoutProps} />
|
|
377
|
+
)
|
|
378
|
+
)
|
|
353
379
|
}
|