ordering-ui-react-native 0.17.93 → 0.17.95
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/AddressForm/index.tsx +2 -2
- package/themes/original/src/components/BusinessProductsListing/index.tsx +1 -1
- package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +1 -1
- package/themes/original/src/components/Cart/index.tsx +39 -4
- package/themes/original/src/components/CartContent/index.tsx +29 -28
- package/themes/original/src/components/Checkout/index.tsx +18 -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/OrderSummary/index.tsx +24 -1
- package/themes/original/src/components/ProductForm/index.tsx +29 -2
- package/themes/original/src/components/ServiceForm/index.tsx +24 -1
- package/themes/original/src/components/SignupForm/index.tsx +16 -11
- package/themes/original/src/components/UserFormDetails/index.tsx +44 -6
- package/themes/original/src/config/constants.tsx +10 -0
- package/themes/original/src/types/index.tsx +13 -2
- package/themes/original/src/utils/index.tsx +5 -0
package/package.json
CHANGED
|
@@ -364,7 +364,7 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
364
364
|
if (
|
|
365
365
|
orderState.loading &&
|
|
366
366
|
!addressesList &&
|
|
367
|
-
orderState
|
|
367
|
+
orderState?.options?.address &&
|
|
368
368
|
auth &&
|
|
369
369
|
!afterSignup
|
|
370
370
|
) {
|
|
@@ -372,7 +372,7 @@ const AddressFormUI = (props: AddressFormParams) => {
|
|
|
372
372
|
? navigation.navigate('BottomTab')
|
|
373
373
|
: navigation.navigate('Business');
|
|
374
374
|
}
|
|
375
|
-
}, [orderState
|
|
375
|
+
}, [orderState?.options?.address]);
|
|
376
376
|
|
|
377
377
|
useEffect(() => {
|
|
378
378
|
if (alertState.open && alertState?.key !== 'ERROR_MAX_LIMIT_LOCATION') {
|
|
@@ -415,7 +415,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
|
|
|
415
415
|
<BackgroundGray isIos={Platform.OS === 'ios'} />
|
|
416
416
|
)}
|
|
417
417
|
<IOScrollView
|
|
418
|
-
stickyHeaderIndices={[business?.professionals?.length > 0 ? 4 :
|
|
418
|
+
stickyHeaderIndices={[business?.professionals?.length > 0 ? 4 : 2]}
|
|
419
419
|
style={{
|
|
420
420
|
...styles.mainContainer,
|
|
421
421
|
marginBottom: currentCart?.products?.length > 0 && categoryState.products.length !== 0 ?
|
|
@@ -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)) ?? {}
|
|
@@ -179,6 +186,19 @@ const CartUI = (props: any) => {
|
|
|
179
186
|
return acc = acc
|
|
180
187
|
}, cart?.subtotal)
|
|
181
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
|
+
|
|
182
202
|
return (
|
|
183
203
|
<CContainer>
|
|
184
204
|
{openUpselling && (
|
|
@@ -486,6 +506,21 @@ const CartUI = (props: any) => {
|
|
|
486
506
|
)}
|
|
487
507
|
</OSBill>
|
|
488
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
|
+
)}
|
|
489
524
|
{!isMultiCheckout && (
|
|
490
525
|
<>
|
|
491
526
|
{cart?.valid_products ? (
|
|
@@ -502,7 +537,7 @@ const CartUI = (props: any) => {
|
|
|
502
537
|
isDisabled={(openUpselling && !canOpenUpselling) || subtotalWithTaxes < cart?.minimum || !cart?.valid_address}
|
|
503
538
|
borderColor={theme.colors.primary}
|
|
504
539
|
imgRightSrc={null}
|
|
505
|
-
textStyle={{ color: '
|
|
540
|
+
textStyle={{ color: '#fff', textAlign: 'center', flex: 1 }}
|
|
506
541
|
onClick={() => setOpenUpselling(true)}
|
|
507
542
|
style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
|
|
508
543
|
/>
|
|
@@ -25,37 +25,37 @@ export const CartContent = (props: any) => {
|
|
|
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
|
-
|
|
44
|
+
if (
|
|
45
|
+
(Object.keys(groupKeys).length === 1 && Object.keys(groupKeys)[0] === 'null') ||
|
|
46
|
+
Object.keys(groupKeys).length > 1
|
|
47
|
+
) {
|
|
48
|
+
onNavigationRedirect('CheckoutNavigator', {
|
|
49
49
|
screen: 'MultiCheckout',
|
|
50
50
|
checkCarts: true
|
|
51
51
|
})
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
} else {
|
|
53
|
+
onNavigationRedirect('CheckoutNavigator', {
|
|
54
|
+
screen: 'MultiCheckout',
|
|
55
|
+
cartUuid: cartsAvailable[0]?.group?.uuid
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
return (
|
|
@@ -65,7 +65,7 @@ export const CartContent = (props: any) => {
|
|
|
65
65
|
{isOrderStateCarts && carts?.length > 0 && (
|
|
66
66
|
<>
|
|
67
67
|
{carts.map((cart: any, i: number) => (
|
|
68
|
-
<CCList key={i} style={{ overflow: 'visible' }}>
|
|
68
|
+
<CCList nestedScrollEnabled={true} key={i} style={{ overflow: 'visible' }}>
|
|
69
69
|
{cart.products.length > 0 && (
|
|
70
70
|
<>
|
|
71
71
|
<Cart
|
|
@@ -78,6 +78,7 @@ export const CartContent = (props: any) => {
|
|
|
78
78
|
setIsCartsLoading={setIsCartsLoading}
|
|
79
79
|
isMultiCheckout={isMultiCheckout}
|
|
80
80
|
hideUpselling
|
|
81
|
+
businessConfigs={cart?.business?.configs}
|
|
81
82
|
/>
|
|
82
83
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginHorizontal: -40, marginTop: 20 }} />
|
|
83
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();
|
|
@@ -211,6 +212,11 @@ const CheckoutUI = (props: any) => {
|
|
|
211
212
|
setIsUserDetailsEdit(true)
|
|
212
213
|
}
|
|
213
214
|
|
|
215
|
+
const handlePlaceOrderAsGuest = () => {
|
|
216
|
+
setIsOpen(false)
|
|
217
|
+
handlerClickPlaceOrder && handlerClickPlaceOrder()
|
|
218
|
+
}
|
|
219
|
+
|
|
214
220
|
const handlePaymentMethodClick = (paymethod: any) => {
|
|
215
221
|
setShowGateway({ closedByUser: false, open: true })
|
|
216
222
|
setWebviewPaymethod(paymethod)
|
|
@@ -675,6 +681,8 @@ const CheckoutUI = (props: any) => {
|
|
|
675
681
|
isCartPending={cart?.status === 2}
|
|
676
682
|
onNavigationRedirect={onNavigationRedirect}
|
|
677
683
|
placeSpotTypes={placeSpotTypes}
|
|
684
|
+
businessConfigs={businessConfigs}
|
|
685
|
+
maxDate={maxDate}
|
|
678
686
|
/>
|
|
679
687
|
</>
|
|
680
688
|
)}
|
|
@@ -711,6 +719,14 @@ const CheckoutUI = (props: any) => {
|
|
|
711
719
|
{t('WARNING_INVALID_PRODUCTS_CHECKOUT', 'To continue with your checkout, please remove from your cart the products that are not available.')}
|
|
712
720
|
</OText>
|
|
713
721
|
)}
|
|
722
|
+
{!cart?.valid_preorder && (
|
|
723
|
+
<OText
|
|
724
|
+
color={theme.colors.error}
|
|
725
|
+
size={12}
|
|
726
|
+
>
|
|
727
|
+
{t('INVALID_CART_MOMENT', 'Selected schedule time is invalid, please select a schedule into the business schedule interval.')}
|
|
728
|
+
</OText>
|
|
729
|
+
)}
|
|
714
730
|
{options.type === 1 &&
|
|
715
731
|
validationFields?.fields?.checkout?.driver_tip?.enabled &&
|
|
716
732
|
validationFields?.fields?.checkout?.driver_tip?.required &&
|
|
@@ -754,6 +770,7 @@ const CheckoutUI = (props: any) => {
|
|
|
754
770
|
togglePhoneUpdate={togglePhoneUpdate}
|
|
755
771
|
requiredFields={requiredFields}
|
|
756
772
|
hideUpdateButton
|
|
773
|
+
handlePlaceOrderAsGuest={handlePlaceOrderAsGuest}
|
|
757
774
|
onClose={() => {
|
|
758
775
|
setIsOpen(false)
|
|
759
776
|
handlePlaceOrder(null, true)
|
|
@@ -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
|
`}
|
|
@@ -26,6 +26,7 @@ import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
|
26
26
|
import { TaxInformation } from '../TaxInformation';
|
|
27
27
|
import { TouchableOpacity } from 'react-native';
|
|
28
28
|
import { OAlert } from '../../../../../src/components/shared'
|
|
29
|
+
import { MomentOption } from '../MomentOption';
|
|
29
30
|
|
|
30
31
|
const OrderSummaryUI = (props: any) => {
|
|
31
32
|
const {
|
|
@@ -38,7 +39,14 @@ const OrderSummaryUI = (props: any) => {
|
|
|
38
39
|
commentState,
|
|
39
40
|
handleChangeComment,
|
|
40
41
|
onNavigationRedirect,
|
|
41
|
-
handleRemoveOfferClick
|
|
42
|
+
handleRemoveOfferClick,
|
|
43
|
+
preorderSlotInterval,
|
|
44
|
+
preorderLeadTime,
|
|
45
|
+
preorderTimeRange,
|
|
46
|
+
preorderMaximumDays,
|
|
47
|
+
preorderMinimumDays,
|
|
48
|
+
cateringTypes,
|
|
49
|
+
maxDate
|
|
42
50
|
} = props;
|
|
43
51
|
|
|
44
52
|
const theme = useTheme()
|
|
@@ -339,6 +347,21 @@ const OrderSummaryUI = (props: any) => {
|
|
|
339
347
|
)}
|
|
340
348
|
</OSBill>
|
|
341
349
|
)}
|
|
350
|
+
{cateringTypes.includes(orderState?.options?.type) && maxDate && cart?.business && (
|
|
351
|
+
<View>
|
|
352
|
+
<MomentOption
|
|
353
|
+
maxDate={maxDate}
|
|
354
|
+
cateringPreorder
|
|
355
|
+
isCart
|
|
356
|
+
preorderSlotInterval={preorderSlotInterval}
|
|
357
|
+
preorderLeadTime={preorderLeadTime}
|
|
358
|
+
preorderTimeRange={preorderTimeRange}
|
|
359
|
+
preorderMaximumDays={preorderMaximumDays}
|
|
360
|
+
preorderMinimumDays={preorderMinimumDays}
|
|
361
|
+
business={cart?.business}
|
|
362
|
+
/>
|
|
363
|
+
</View>
|
|
364
|
+
)}
|
|
342
365
|
<OModal
|
|
343
366
|
open={openTaxModal.open}
|
|
344
367
|
onClose={() => setOpenTaxModal({ open: false, data: null, type: '' })}
|
|
@@ -19,8 +19,10 @@ import {
|
|
|
19
19
|
useOrder,
|
|
20
20
|
useUtils,
|
|
21
21
|
ToastType,
|
|
22
|
-
useToast
|
|
22
|
+
useToast,
|
|
23
|
+
useConfig
|
|
23
24
|
} from 'ordering-components/native';
|
|
25
|
+
import uuid from 'react-native-uuid';
|
|
24
26
|
import { useTheme } from 'styled-components/native';
|
|
25
27
|
import { ProductIngredient } from '../ProductIngredient';
|
|
26
28
|
import { ProductOption } from '../ProductOption';
|
|
@@ -52,6 +54,7 @@ import { ProductOptionSubOption } from '../ProductOptionSubOption';
|
|
|
52
54
|
import { NotFoundSource } from '../NotFoundSource';
|
|
53
55
|
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
54
56
|
import NavBar from '../NavBar';
|
|
57
|
+
import { orderTypeList } from '../../utils';
|
|
55
58
|
const windowWidth = Dimensions.get('window').width;
|
|
56
59
|
|
|
57
60
|
export const ProductOptionsUI = (props: any) => {
|
|
@@ -71,7 +74,9 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
71
74
|
handleChangeSuboptionState,
|
|
72
75
|
handleChangeCommentState,
|
|
73
76
|
productObject,
|
|
74
|
-
productAddedToCartLength
|
|
77
|
+
productAddedToCartLength,
|
|
78
|
+
actionStatus,
|
|
79
|
+
handleCreateGuestUser
|
|
75
80
|
} = props;
|
|
76
81
|
|
|
77
82
|
const theme = useTheme();
|
|
@@ -178,6 +183,7 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
178
183
|
const [, t] = useLanguage();
|
|
179
184
|
const [orderState] = useOrder();
|
|
180
185
|
const [{ auth }] = useSession();
|
|
186
|
+
const [{ configs }] = useConfig()
|
|
181
187
|
const { product, loading, error } = productObject;
|
|
182
188
|
const [gallery, setGallery] = useState([])
|
|
183
189
|
const [thumbsSwiper, setThumbsSwiper] = useState(0)
|
|
@@ -198,6 +204,9 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
198
204
|
const [isScrollAvailable, setIsScrollAvailable] = useState(null)
|
|
199
205
|
const [editionsLayoutY, setEditionsLayoutY] = useState(null)
|
|
200
206
|
|
|
207
|
+
const guestCheckoutEnabled = configs?.guest_checkout_enabled?.value === '1'
|
|
208
|
+
const orderTypeEnabled = !orderTypeList[orderState?.options?.type - 1] || configs?.allowed_order_types_guest_checkout?.value?.includes(orderTypeList[orderState?.options?.type - 1])
|
|
209
|
+
|
|
201
210
|
const isError = (id: number) => {
|
|
202
211
|
let bgColor = theme.colors.white;
|
|
203
212
|
if (errors[`id:${id}`]) {
|
|
@@ -294,6 +303,11 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
294
303
|
}
|
|
295
304
|
}
|
|
296
305
|
|
|
306
|
+
const handleUpdateGuest = () => {
|
|
307
|
+
const guestToken = uuid.v4()
|
|
308
|
+
if (guestToken) handleCreateGuestUser({ guest_token: guestToken })
|
|
309
|
+
}
|
|
310
|
+
|
|
297
311
|
const handleOnLayout = (event: any, optionId: any) => {
|
|
298
312
|
const _optionLayout = { ...optionLayout }
|
|
299
313
|
const optionKey = 'id:' + optionId
|
|
@@ -472,9 +486,22 @@ export const ProductOptionsUI = (props: any) => {
|
|
|
472
486
|
height: 44,
|
|
473
487
|
borderColor: theme.colors.primary,
|
|
474
488
|
backgroundColor: theme.colors.white,
|
|
489
|
+
paddingLeft: 0,
|
|
490
|
+
paddingRight: 0
|
|
475
491
|
}}
|
|
476
492
|
/>
|
|
477
493
|
)}
|
|
494
|
+
{!auth && guestCheckoutEnabled && orderTypeEnabled && (
|
|
495
|
+
<TouchableOpacity style={{ marginTop: 10 }} onPress={handleUpdateGuest}>
|
|
496
|
+
{actionStatus?.loading ? (
|
|
497
|
+
<Placeholder Animation={Fade}>
|
|
498
|
+
<PlaceholderLine width={60} height={20} />
|
|
499
|
+
</Placeholder>
|
|
500
|
+
) : (
|
|
501
|
+
<OText color={theme.colors.primary} size={13}>{t('WITH_GUEST_USER', 'With Guest user')}</OText>
|
|
502
|
+
)}
|
|
503
|
+
</TouchableOpacity>
|
|
504
|
+
)}
|
|
478
505
|
</View>
|
|
479
506
|
)
|
|
480
507
|
}
|
|
@@ -11,6 +11,8 @@ import FeatherIcon from 'react-native-vector-icons/Feather';
|
|
|
11
11
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
12
12
|
import { ServiceFormParams } from '../../types'
|
|
13
13
|
import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
|
|
14
|
+
import uuid from 'react-native-uuid';
|
|
15
|
+
import { orderTypeList } from '../../utils'
|
|
14
16
|
|
|
15
17
|
import {
|
|
16
18
|
ProductForm as ProductFormController,
|
|
@@ -45,7 +47,9 @@ const ServiceFormUI = (props: ServiceFormParams) => {
|
|
|
45
47
|
maxProductQuantity,
|
|
46
48
|
onClose,
|
|
47
49
|
professionalListState,
|
|
48
|
-
isCartProduct
|
|
50
|
+
isCartProduct,
|
|
51
|
+
actionStatus,
|
|
52
|
+
handleCreateGuestUser
|
|
49
53
|
} = props
|
|
50
54
|
|
|
51
55
|
const theme = useTheme()
|
|
@@ -65,6 +69,9 @@ const ServiceFormUI = (props: ServiceFormParams) => {
|
|
|
65
69
|
const [isOpen, setIsOpen] = useState(false)
|
|
66
70
|
const [currentProfessional, setCurrentProfessional] = useState<any>(null)
|
|
67
71
|
|
|
72
|
+
const guestCheckoutEnabled = configs?.guest_checkout_enabled?.value === '1'
|
|
73
|
+
const orderTypeEnabled = !orderTypeList[orderState?.options?.type - 1] || configs?.allowed_order_types_guest_checkout?.value?.includes(orderTypeList[orderState?.options?.type - 1])
|
|
74
|
+
|
|
68
75
|
const dropdownRef = useRef<any>(null)
|
|
69
76
|
|
|
70
77
|
const styles = StyleSheet.create({
|
|
@@ -140,6 +147,11 @@ const ServiceFormUI = (props: ServiceFormParams) => {
|
|
|
140
147
|
)
|
|
141
148
|
}
|
|
142
149
|
|
|
150
|
+
const handleUpdateGuest = () => {
|
|
151
|
+
const guestToken = uuid.v4()
|
|
152
|
+
if (guestToken) handleCreateGuestUser({ guest_token: guestToken })
|
|
153
|
+
}
|
|
154
|
+
|
|
143
155
|
const customDayHeaderStylesCallback = () => {
|
|
144
156
|
return {
|
|
145
157
|
textStyle: {
|
|
@@ -563,6 +575,17 @@ const ServiceFormUI = (props: ServiceFormParams) => {
|
|
|
563
575
|
}}
|
|
564
576
|
/>
|
|
565
577
|
)}
|
|
578
|
+
{!auth && guestCheckoutEnabled && orderTypeEnabled && (
|
|
579
|
+
<TouchableOpacity style={{ marginTop: 10 }} onPress={handleUpdateGuest}>
|
|
580
|
+
{actionStatus?.loading ? (
|
|
581
|
+
<Placeholder Animation={Fade}>
|
|
582
|
+
<PlaceholderLine width={60} height={20} />
|
|
583
|
+
</Placeholder>
|
|
584
|
+
) : (
|
|
585
|
+
<OText color={theme.colors.primary} size={13}>{t('WITH_GUEST_USER', 'With Guest user')}</OText>
|
|
586
|
+
)}
|
|
587
|
+
</TouchableOpacity>
|
|
588
|
+
)}
|
|
566
589
|
</ButtonWrapper>
|
|
567
590
|
</Container>
|
|
568
591
|
)}
|
|
@@ -83,7 +83,8 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
83
83
|
signUpTab,
|
|
84
84
|
useSignUpFullDetails,
|
|
85
85
|
useSignUpOtpEmail,
|
|
86
|
-
useSignUpOtpCellphone
|
|
86
|
+
useSignUpOtpCellphone,
|
|
87
|
+
isGuest
|
|
87
88
|
} = props;
|
|
88
89
|
|
|
89
90
|
const theme = useTheme();
|
|
@@ -465,15 +466,19 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
465
466
|
|
|
466
467
|
return (
|
|
467
468
|
<View>
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
469
|
+
{isGuest ? (
|
|
470
|
+
<OText style={{ textAlign: 'center', marginBottom: 10 }} size={18}>{t('SIGNUP', 'Signup')}</OText>
|
|
471
|
+
) : (
|
|
472
|
+
<NavBar
|
|
473
|
+
title={t('SIGNUP', 'Signup')}
|
|
474
|
+
titleAlign={'center'}
|
|
475
|
+
onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
|
|
476
|
+
showCall={false}
|
|
477
|
+
btnStyle={{ paddingLeft: 0 }}
|
|
478
|
+
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
479
|
+
titleStyle={{ marginLeft: 0, marginRight: 0 }}
|
|
480
|
+
/>
|
|
481
|
+
)}
|
|
477
482
|
<FormSide>
|
|
478
483
|
{((Number(useSignUpFullDetails) + Number(useSignUpOtpEmail) + Number(useSignUpOtpCellphone)) > 1) && (
|
|
479
484
|
<SignupWith>
|
|
@@ -893,7 +898,7 @@ const SignupFormUI = (props: SignupParams) => {
|
|
|
893
898
|
</View>
|
|
894
899
|
)
|
|
895
900
|
}
|
|
896
|
-
{configs && Object.keys(configs).length > 0 && (
|
|
901
|
+
{configs && Object.keys(configs).length > 0 && !isGuest && (
|
|
897
902
|
(((configs?.facebook_login?.value === 'true' || configs?.facebook_login?.value === '1') && configs?.facebook_id?.value && facebookLoginEnabled) ||
|
|
898
903
|
((configs?.google_login_client_id?.value !== '' && configs?.google_login_client_id?.value !== null) && googleLoginEnabled) ||
|
|
899
904
|
((configs?.apple_login_client_id?.value !== '' && configs?.apple_login_client_id?.value !== null) && appleLoginEnabled)) &&
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { Platform, StyleSheet, TouchableOpacity } from 'react-native';
|
|
2
|
+
import { Platform, StyleSheet, TouchableOpacity, ScrollView } from 'react-native';
|
|
3
3
|
import { useSession, useLanguage, ToastType, useToast, useConfig } from 'ordering-components/native';
|
|
4
4
|
import { useTheme } from 'styled-components/native';
|
|
5
5
|
import { useForm, Controller } from 'react-hook-form';
|
|
6
|
+
import { SignupForm } from '../SignupForm'
|
|
6
7
|
|
|
7
8
|
import { UDForm, UDLoader, UDWrapper, WrapperPhone } from './styles';
|
|
8
9
|
|
|
9
|
-
import { OText, OButton, OInput } from '../shared';
|
|
10
|
+
import { OText, OButton, OInput, OModal } from '../shared';
|
|
10
11
|
|
|
11
12
|
import { PhoneInputNumber } from '../PhoneInputNumber';
|
|
12
13
|
import { sortInputFields } from '../../utils';
|
|
@@ -27,6 +28,8 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
27
28
|
phoneUpdate,
|
|
28
29
|
hideUpdateButton,
|
|
29
30
|
setWillVerifyOtpState,
|
|
31
|
+
handlePlaceOrderAsGuest,
|
|
32
|
+
isCheckout
|
|
30
33
|
} = props;
|
|
31
34
|
|
|
32
35
|
const theme = useTheme();
|
|
@@ -68,10 +71,11 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
68
71
|
const [, { showToast }] = useToast();
|
|
69
72
|
const { handleSubmit, control, errors, setValue } = useForm();
|
|
70
73
|
|
|
71
|
-
const [{ user }] = useSession();
|
|
74
|
+
const [{ user }, { login }] = useSession();
|
|
72
75
|
const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null);
|
|
73
76
|
const [isValid, setIsValid] = useState(false)
|
|
74
77
|
const [isChanged, setIsChanged] = useState(false)
|
|
78
|
+
const [isModalOpen, setIsModalOpen] = useState(false)
|
|
75
79
|
const [phoneInputData, setPhoneInputData] = useState({
|
|
76
80
|
error: '',
|
|
77
81
|
phone: {
|
|
@@ -82,6 +86,14 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
82
86
|
|
|
83
87
|
const showInputPhoneNumber = (validationFields?.fields?.checkout?.cellphone?.enabled ?? false) || configs?.verification_phone_required?.value === '1'
|
|
84
88
|
|
|
89
|
+
const handleSuccessSignup = (user: any) => {
|
|
90
|
+
login({
|
|
91
|
+
user,
|
|
92
|
+
token: user?.session?.access_token
|
|
93
|
+
})
|
|
94
|
+
handlePlaceOrderAsGuest && handlePlaceOrderAsGuest()
|
|
95
|
+
}
|
|
96
|
+
|
|
85
97
|
const getInputRules = (field: any) => {
|
|
86
98
|
const rules: any = {
|
|
87
99
|
required: isRequiredField(field.code)
|
|
@@ -187,6 +199,11 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
187
199
|
handleChangeInput(countryCode, true);
|
|
188
200
|
}
|
|
189
201
|
|
|
202
|
+
const handleClickBtn = () => {
|
|
203
|
+
if (!user?.guest_id) handleSubmit(onSubmit)
|
|
204
|
+
else setIsModalOpen(true)
|
|
205
|
+
}
|
|
206
|
+
|
|
190
207
|
useEffect(() => {
|
|
191
208
|
if (Object.keys(errors).length > 0) {
|
|
192
209
|
const list = Object.values(errors);
|
|
@@ -423,17 +440,38 @@ export const UserFormDetailsUI = (props: any) => {
|
|
|
423
440
|
text={
|
|
424
441
|
formState.loading
|
|
425
442
|
? t('UPDATING', 'Updating...')
|
|
426
|
-
:
|
|
443
|
+
: ((isCheckout && !!user?.guest_id)
|
|
444
|
+
? t('SIGN_UP_AND_PLACE_ORDER', 'Sign up and place order')
|
|
445
|
+
: t('CONTINUE', 'Continue'))
|
|
427
446
|
}
|
|
428
447
|
bgColor={theme.colors.white}
|
|
429
448
|
textStyle={{ color: theme.colors.primary, fontSize: 14 }}
|
|
430
449
|
borderColor={theme.colors.primary}
|
|
431
|
-
isDisabled={formState.loading || !isValid}
|
|
450
|
+
isDisabled={!user?.guest_id && (formState.loading || !isValid)}
|
|
432
451
|
imgRightSrc={null}
|
|
433
452
|
style={{ borderRadius: 7.6, shadowOpacity: 0, width: '100%', borderWidth: 1, marginTop: 20, marginBottom: 20 }}
|
|
434
|
-
onClick={
|
|
453
|
+
onClick={handleClickBtn}
|
|
435
454
|
/>
|
|
436
455
|
)}
|
|
456
|
+
{isCheckout && !!user?.guest_id && (
|
|
457
|
+
<TouchableOpacity style={{ marginTop: 10 }} onPress={() => handlePlaceOrderAsGuest()}>
|
|
458
|
+
<OText color={theme.colors.primary} style={{ textAlign: 'center' }}>{t('PLACE_ORDER_AS_GUEST', 'Place order as guest')}</OText>
|
|
459
|
+
</TouchableOpacity>
|
|
460
|
+
)}
|
|
461
|
+
<OModal
|
|
462
|
+
open={isModalOpen}
|
|
463
|
+
onClose={() => setIsModalOpen(false)}
|
|
464
|
+
>
|
|
465
|
+
<ScrollView style={{ paddingHorizontal: 20, width: '100%'}}>
|
|
466
|
+
<SignupForm
|
|
467
|
+
handleSuccessSignup={handleSuccessSignup}
|
|
468
|
+
isGuest
|
|
469
|
+
signupButtonText={t('SIGNUP', 'Signup')}
|
|
470
|
+
useSignupByEmail
|
|
471
|
+
useChekoutFileds
|
|
472
|
+
/>
|
|
473
|
+
</ScrollView>
|
|
474
|
+
</OModal>
|
|
437
475
|
</>
|
|
438
476
|
);
|
|
439
477
|
};
|
|
@@ -29,5 +29,15 @@ export const ORDER_TYPES = [
|
|
|
29
29
|
value: 5,
|
|
30
30
|
content: 'DRIVE_THRU',
|
|
31
31
|
description: 'ORDERTYPE_DESCRIPTION_DRIVETHRU',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
value: 7,
|
|
35
|
+
content: 'CATERING_DELIVERY',
|
|
36
|
+
description: 'ORDERTYPE_DESCRIPTION_CATERING_DELIVERY',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
value: 8,
|
|
40
|
+
content: 'CATERING_PICKUP',
|
|
41
|
+
description: 'ORDERTYPE_DESCRIPTION_CATERING_PICKUP',
|
|
32
42
|
}
|
|
33
43
|
]
|
|
@@ -118,6 +118,7 @@ export interface SignupParams {
|
|
|
118
118
|
useSignUpOtpEmail?: boolean;
|
|
119
119
|
useSignUpOtpCellphone?: boolean;
|
|
120
120
|
willVerifyOtpState?: boolean;
|
|
121
|
+
isGuest?: any;
|
|
121
122
|
numOtpInputs?: number;
|
|
122
123
|
handleChangePromotions: () => void;
|
|
123
124
|
handleChangeInput?: (in1: any, in2: any) => void;
|
|
@@ -318,7 +319,7 @@ export interface SingleProductCardParams {
|
|
|
318
319
|
navigation?: any;
|
|
319
320
|
isPreviously?: any;
|
|
320
321
|
isProductId?: any;
|
|
321
|
-
viewString?: string;
|
|
322
|
+
viewString?: string;
|
|
322
323
|
}
|
|
323
324
|
export interface BusinessInformationParams {
|
|
324
325
|
navigation?: any,
|
|
@@ -544,6 +545,14 @@ export interface MomentOptionParams {
|
|
|
544
545
|
dateSelected?: any;
|
|
545
546
|
timeSelected?: any;
|
|
546
547
|
isAsap?: boolean;
|
|
548
|
+
cateringPreorder?: boolean,
|
|
549
|
+
isCart?: boolean,
|
|
550
|
+
preorderLeadTime?: number,
|
|
551
|
+
business?: any,
|
|
552
|
+
getActualSchedule?: any,
|
|
553
|
+
preorderMaximumDays?: number,
|
|
554
|
+
preorderMinimumDays?: number,
|
|
555
|
+
isPage?: boolean,
|
|
547
556
|
handleAsap: () => {};
|
|
548
557
|
handleChangeDate: (value: any) => {};
|
|
549
558
|
handleChangeTime: (value: any) => {};
|
|
@@ -761,7 +770,9 @@ export interface ServiceFormParams {
|
|
|
761
770
|
professionalList: any,
|
|
762
771
|
productObject?: any,
|
|
763
772
|
professionalListState?: any,
|
|
764
|
-
isCartProduct?: any
|
|
773
|
+
isCartProduct?: any,
|
|
774
|
+
actionStatus?: any,
|
|
775
|
+
handleCreateGuestUser?: any
|
|
765
776
|
}
|
|
766
777
|
|
|
767
778
|
export interface ProfessionalFilterParams {
|
|
@@ -10,6 +10,11 @@ const theme = useTheme()
|
|
|
10
10
|
|
|
11
11
|
export const flatArray = (arr: any) => [].concat(...arr)
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* List of order type
|
|
15
|
+
*/
|
|
16
|
+
export const orderTypeList = ['delivery', 'pickup', 'eatin', 'curbside', 'drivethru', 'seatdelivery']
|
|
17
|
+
|
|
13
18
|
/**
|
|
14
19
|
* Function to return the traduction depending of a key 't'
|
|
15
20
|
* @param {string} key for traduction
|