ordering-ui-react-native 0.16.83-release → 0.16.84-release
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/themes/original/src/components/BusinessPreorder/index.tsx +96 -15
- package/themes/original/src/components/Cart/index.tsx +9 -2
- package/themes/original/src/components/MultiCheckout/index.tsx +26 -0
- package/themes/original/src/components/OrderProgress/index.tsx +4 -4
- package/themes/original/src/components/PaymentOptions/index.tsx +1 -1
- package/themes/original/src/utils/index.tsx +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react'
|
|
2
2
|
import { TouchableOpacity, StyleSheet, View, Dimensions, Platform } from 'react-native'
|
|
3
3
|
import { useLanguage, useUtils, useConfig, useOrder, MomentOption } from 'ordering-components/native'
|
|
4
|
-
import { OButton, OText } from '../shared'
|
|
4
|
+
import { OButton, OIcon, OText } from '../shared'
|
|
5
5
|
import { useTheme } from 'styled-components/native'
|
|
6
6
|
import IconAntDesign from 'react-native-vector-icons/AntDesign'
|
|
7
7
|
import FastImage from 'react-native-fast-image'
|
|
@@ -37,7 +37,10 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
37
37
|
handleChangeDate,
|
|
38
38
|
handleChangeTime,
|
|
39
39
|
handleAsap,
|
|
40
|
-
|
|
40
|
+
getActualSchedule,
|
|
41
|
+
isAsap,
|
|
42
|
+
cateringPreorder,
|
|
43
|
+
preorderLeadTime
|
|
41
44
|
} = props
|
|
42
45
|
|
|
43
46
|
const theme = useTheme()
|
|
@@ -52,6 +55,8 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
52
55
|
const [datesWhitelist, setDateWhitelist] = useState<any>([{ start: null, end: null }])
|
|
53
56
|
const [isEnabled, setIsEnabled] = useState(false)
|
|
54
57
|
const { top } = useSafeAreaInsets()
|
|
58
|
+
const is12hours = configs?.dates_moment_format?.value?.includes('hh:mm')
|
|
59
|
+
|
|
55
60
|
const showOrderTime = (selectedPreorderType === 1 && Object.keys(menu)?.length > 0) || selectedPreorderType === 0
|
|
56
61
|
const isPreOrderSetting = configs?.preorder_status_enabled?.value === '1'
|
|
57
62
|
const styles = StyleSheet.create({
|
|
@@ -252,10 +257,45 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
252
257
|
|
|
253
258
|
useEffect(() => {
|
|
254
259
|
if (selectDate === null) return
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
260
|
+
if (cateringPreorder) {
|
|
261
|
+
let _timeLists = []
|
|
262
|
+
const schedule = business && getActualSchedule()
|
|
263
|
+
if (!schedule && cateringPreorder && Object.keys(business)?.length > 0) {
|
|
264
|
+
return
|
|
265
|
+
}
|
|
266
|
+
_timeLists = hoursList
|
|
267
|
+
.filter(hour => ((Object.keys(business || {})?.length === 0) || schedule?.lapses?.some((lapse: any) =>
|
|
268
|
+
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}`))) &&
|
|
269
|
+
moment(dateSelected + ` ${hour.startTime}`) < moment(dateSelected + ` ${hour.endTime}`) &&
|
|
270
|
+
(moment().add(preorderLeadTime, 'minutes') < moment(dateSelected + ` ${hour.startTime}`) || !cateringPreorder))
|
|
271
|
+
.map(hour => {
|
|
272
|
+
return {
|
|
273
|
+
value: hour.startTime,
|
|
274
|
+
text: is12hours ? (
|
|
275
|
+
hour.startTime.includes('12')
|
|
276
|
+
? `${hour.startTime}PM`
|
|
277
|
+
: parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'hh:mma' })
|
|
278
|
+
) : (
|
|
279
|
+
parseTime(moment(hour.startTime, 'HH:mm'), { outputFormat: 'HH:mm' })
|
|
280
|
+
),
|
|
281
|
+
endText: is12hours ? (
|
|
282
|
+
hour.endTime.includes('12')
|
|
283
|
+
? `${hour.endTime}PM`
|
|
284
|
+
: parseTime(moment(hour.endTime, 'HH:mm'), { outputFormat: 'hh:mma' })
|
|
285
|
+
) : (
|
|
286
|
+
parseTime(moment(hour.endTime, 'HH:mm'), { outputFormat: 'HH:mm' })
|
|
287
|
+
)
|
|
288
|
+
}
|
|
289
|
+
})
|
|
290
|
+
if (_timeLists?.length > 0) {
|
|
291
|
+
setTimeList(_timeLists)
|
|
292
|
+
}
|
|
293
|
+
} else {
|
|
294
|
+
const selectedMenu = Object.keys(menu).length > 0 ? (menu?.use_business_schedule ? business : menu) : business
|
|
295
|
+
const _times = getTimes(selectDate, selectedMenu)
|
|
296
|
+
setTimeList(_times)
|
|
297
|
+
}
|
|
298
|
+
}, [selectDate, menu, business, cateringPreorder, hoursList, dateSelected])
|
|
259
299
|
|
|
260
300
|
useEffect(() => {
|
|
261
301
|
if (selectedPreorderType === 0 && Object.keys(menu).length > 0) setMenu({})
|
|
@@ -263,6 +303,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
263
303
|
|
|
264
304
|
useEffect(() => {
|
|
265
305
|
if (dateSelected) {
|
|
306
|
+
|
|
266
307
|
const dateParts = dateSelected.split('-')
|
|
267
308
|
const _dateSelected = new Date(dateParts[0], dateParts[1] - 1, dateParts[2])
|
|
268
309
|
setSelectedDate(_dateSelected)
|
|
@@ -302,7 +343,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
302
343
|
/>
|
|
303
344
|
</View>
|
|
304
345
|
</BusinessInfoWrapper>
|
|
305
|
-
{isPreOrderSetting && (
|
|
346
|
+
{isPreOrderSetting && !cateringPreorder && (
|
|
306
347
|
<PreorderTypeWrapper>
|
|
307
348
|
<OText
|
|
308
349
|
size={16}
|
|
@@ -415,19 +456,36 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
415
456
|
/>
|
|
416
457
|
)}
|
|
417
458
|
</View>
|
|
418
|
-
<TimeListWrapper nestedScrollEnabled={true}>
|
|
419
|
-
{(isEnabled && timeList?.length > 0) ? (
|
|
459
|
+
<TimeListWrapper nestedScrollEnabled={true} cateringPreorder={cateringPreorder}>
|
|
460
|
+
{((isEnabled || cateringPreorder) && timeList?.length > 0) ? (
|
|
420
461
|
<TimeContentWrapper>
|
|
421
462
|
{timeList.map((time: any, i: number) => (
|
|
422
463
|
<TouchableOpacity key={i} onPress={() => handleChangeTime(time.value)}>
|
|
423
|
-
<TimeItem active={timeSelected === time.value}>
|
|
464
|
+
<TimeItem active={timeSelected === time.value} cateringPreorder={cateringPreorder}>
|
|
465
|
+
{cateringPreorder && (
|
|
466
|
+
<>
|
|
467
|
+
{timeSelected === time.value ? (
|
|
468
|
+
<OIcon
|
|
469
|
+
src={theme.images.general.option_checked}
|
|
470
|
+
width={18}
|
|
471
|
+
style={{ marginEnd: 24, bottom: 2 }}
|
|
472
|
+
/>
|
|
473
|
+
) : (
|
|
474
|
+
<OIcon
|
|
475
|
+
src={theme.images.general.option_normal}
|
|
476
|
+
width={18}
|
|
477
|
+
style={{ marginEnd: 24, bottom: 2 }}
|
|
478
|
+
/>
|
|
479
|
+
)}
|
|
480
|
+
</>
|
|
481
|
+
)}
|
|
424
482
|
<OText
|
|
425
|
-
size={
|
|
483
|
+
size={cateringPreorder ? 18 : 16}
|
|
426
484
|
color={timeSelected === time.value ? theme.colors.primary : theme.colors.textNormal}
|
|
427
485
|
style={{
|
|
428
486
|
lineHeight: 24
|
|
429
487
|
}}
|
|
430
|
-
>{time.text}</OText>
|
|
488
|
+
>{time.text} {cateringPreorder && `- ${time.endText}`}</OText>
|
|
431
489
|
</TimeItem>
|
|
432
490
|
</TouchableOpacity>
|
|
433
491
|
))}
|
|
@@ -461,7 +519,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
461
519
|
marginBottom: 12,
|
|
462
520
|
textAlign: 'center'
|
|
463
521
|
}}
|
|
464
|
-
|
|
522
|
+
>
|
|
465
523
|
{t('ERROR_ADD_PRODUCT_BUSINESS_CLOSED', 'The business is closed at the moment')}
|
|
466
524
|
</OText>
|
|
467
525
|
)}
|
|
@@ -480,7 +538,7 @@ const BusinessPreorderUI = (props: BusinessPreorderParams) => {
|
|
|
480
538
|
|
|
481
539
|
export const BusinessPreorder = (props: any) => {
|
|
482
540
|
const [{ configs }] = useConfig()
|
|
483
|
-
|
|
541
|
+
const [orderState] = useOrder()
|
|
484
542
|
const limitDays = parseInt(configs?.max_days_preorder?.value, 10)
|
|
485
543
|
|
|
486
544
|
const currentDate = new Date()
|
|
@@ -492,10 +550,33 @@ export const BusinessPreorder = (props: any) => {
|
|
|
492
550
|
currentDate.setHours(23)
|
|
493
551
|
currentDate.setMinutes(59)
|
|
494
552
|
|
|
553
|
+
const cateringTypeString = orderState?.options?.type === 7
|
|
554
|
+
? 'catering_delivery'
|
|
555
|
+
: orderState?.options?.type === 8
|
|
556
|
+
? 'catering_pickup'
|
|
557
|
+
: null
|
|
558
|
+
|
|
559
|
+
const splitCateringValue = (configName : string) =>
|
|
560
|
+
Object.values(props?.business?.configs || {})
|
|
561
|
+
?.find(config => config?.key === configName)
|
|
562
|
+
?.value?.split('|')
|
|
563
|
+
?.find(val => val.includes(cateringTypeString || ''))?.split(',')[1]
|
|
564
|
+
const preorderSlotInterval = parseInt(splitCateringValue('preorder_slot_interval'))
|
|
565
|
+
const preorderLeadTime = parseInt(splitCateringValue('preorder_lead_time'))
|
|
566
|
+
const preorderTimeRange = parseInt(splitCateringValue('preorder_time_range'))
|
|
567
|
+
const preorderMaximumDays = parseInt(splitCateringValue('preorder_maximum_days'))
|
|
568
|
+
const preorderMinimumDays = parseInt(splitCateringValue('preorder_minimum_days'))
|
|
569
|
+
|
|
495
570
|
const businessPreorderProps = {
|
|
496
571
|
...props,
|
|
497
572
|
UIComponent: BusinessPreorderUI,
|
|
498
|
-
maxDate: currentDate
|
|
573
|
+
maxDate: currentDate,
|
|
574
|
+
preorderLeadTime,
|
|
575
|
+
preorderSlotInterval,
|
|
576
|
+
preorderTimeRange,
|
|
577
|
+
preorderMaximumDays,
|
|
578
|
+
preorderMinimumDays,
|
|
579
|
+
cateringPreorder: !!cateringTypeString
|
|
499
580
|
}
|
|
500
581
|
return <MomentOption {...businessPreorderProps} />
|
|
501
582
|
}
|
|
@@ -43,7 +43,14 @@ const CartUI = (props: any) => {
|
|
|
43
43
|
handleRemoveOfferClick,
|
|
44
44
|
isMultiCheckout,
|
|
45
45
|
hideDeliveryFee,
|
|
46
|
-
hideDriverTip
|
|
46
|
+
hideDriverTip,
|
|
47
|
+
hideCouponInput,
|
|
48
|
+
preorderSlotInterval,
|
|
49
|
+
preorderLeadTime,
|
|
50
|
+
preorderTimeRange,
|
|
51
|
+
preorderMaximumDays,
|
|
52
|
+
preorderMinimumDays,
|
|
53
|
+
cateringTypes
|
|
47
54
|
} = props
|
|
48
55
|
|
|
49
56
|
const theme = useTheme();
|
|
@@ -383,7 +390,7 @@ const CartUI = (props: any) => {
|
|
|
383
390
|
<OText size={12}>-{parsePrice(event.amount, { isTruncable: true })}</OText>
|
|
384
391
|
</OSTable>
|
|
385
392
|
))}
|
|
386
|
-
{isCouponEnabled && !isCartPending && (
|
|
393
|
+
{isCouponEnabled && !isCartPending && !hideCouponInput && (
|
|
387
394
|
<OSTable>
|
|
388
395
|
<OSCoupon>
|
|
389
396
|
<CouponControl
|
|
@@ -23,7 +23,9 @@ import { MultiCartsPaymethodsAndWallets } from '../MultiCartsPaymethodsAndWallet
|
|
|
23
23
|
import { Cart } from '../Cart'
|
|
24
24
|
import { FloatingButton } from '../FloatingButton'
|
|
25
25
|
import { DriverTips } from '../DriverTips'
|
|
26
|
+
import { CouponControl } from '../CouponControl';
|
|
26
27
|
import { DriverTipsContainer } from '../Cart/styles'
|
|
28
|
+
import { OSTable, OSCoupon } from '../OrderSummary/styles';
|
|
27
29
|
|
|
28
30
|
import {
|
|
29
31
|
ChContainer,
|
|
@@ -263,6 +265,29 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
263
265
|
</ChSection>
|
|
264
266
|
)}
|
|
265
267
|
|
|
268
|
+
{
|
|
269
|
+
validationFields?.fields?.checkout?.coupon?.enabled &&
|
|
270
|
+
openCarts.every((cart: any) => cart.business_id && cart.status !== 2) &&
|
|
271
|
+
configs?.multi_business_checkout_coupon_input_style?.value === 'group' &&
|
|
272
|
+
(
|
|
273
|
+
<ChSection>
|
|
274
|
+
<OText size={14} lineHeight={20} color={theme.colors.textNormal}>
|
|
275
|
+
{t('DISCOUNT_COUPON', 'Discount coupon')}
|
|
276
|
+
</OText>
|
|
277
|
+
<OSTable>
|
|
278
|
+
<OSCoupon>
|
|
279
|
+
<CouponControl
|
|
280
|
+
isMulti
|
|
281
|
+
carts={openCarts}
|
|
282
|
+
businessIds={openCarts.map((cart: any) => cart.business_id)}
|
|
283
|
+
price={openCarts.reduce((total: any, cart: any) => total + cart.total, 0)}
|
|
284
|
+
/>
|
|
285
|
+
</OSCoupon>
|
|
286
|
+
</OSTable>
|
|
287
|
+
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginTop: 13, marginHorizontal: -40 }} />
|
|
288
|
+
</ChSection>
|
|
289
|
+
)}
|
|
290
|
+
|
|
266
291
|
<ChSection>
|
|
267
292
|
<ChCarts>
|
|
268
293
|
<CartsHeader>
|
|
@@ -276,6 +301,7 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
276
301
|
cart={cart}
|
|
277
302
|
cartuuid={cart.uuid}
|
|
278
303
|
isMultiCheckout
|
|
304
|
+
hideCouponInput={configs?.multi_business_checkout_coupon_input_style?.value === 'group'}
|
|
279
305
|
hideDeliveryFee={configs?.multi_business_checkout_show_combined_delivery_fee?.value === '1'}
|
|
280
306
|
hideDriverTip={configs?.multi_business_checkout_show_combined_driver_tip?.value === '1'}
|
|
281
307
|
onNavigationRedirect={(route: string, params: any) => props.navigation.navigate(route, params)}
|
|
@@ -125,11 +125,11 @@ const OrderProgressUI = (props: any) => {
|
|
|
125
125
|
<View style={styles.logoWrapper}>
|
|
126
126
|
<FastImage
|
|
127
127
|
style={{ width: 50, height: 50 }}
|
|
128
|
-
source={{
|
|
128
|
+
source={orderList?.orders.length === 1 ? {
|
|
129
129
|
uri: optimizeImage(lastOrder?.business?.logo, 'h_50,c_limit'),
|
|
130
130
|
priority: FastImage.priority.normal,
|
|
131
|
-
}}
|
|
132
|
-
resizeMode={FastImage.resizeMode.
|
|
131
|
+
} : theme.images.logos.logotype}
|
|
132
|
+
resizeMode={FastImage.resizeMode.contain}
|
|
133
133
|
/>
|
|
134
134
|
</View>
|
|
135
135
|
<View style={{
|
|
@@ -198,7 +198,7 @@ export const OrderProgress = (props: any) => {
|
|
|
198
198
|
useDefualtSessionManager: true,
|
|
199
199
|
paginationSettings: {
|
|
200
200
|
initialPage: 1,
|
|
201
|
-
pageSize:
|
|
201
|
+
pageSize: 10,
|
|
202
202
|
controlType: 'infinity'
|
|
203
203
|
}
|
|
204
204
|
}
|
|
@@ -75,7 +75,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
75
75
|
case 'paypal':
|
|
76
76
|
return theme.images.general.paypal
|
|
77
77
|
case 'stripe':
|
|
78
|
-
return theme.images.general.
|
|
78
|
+
return theme.images.general.creditCard
|
|
79
79
|
case 'stripe_direct':
|
|
80
80
|
return theme.images.general.stripecc
|
|
81
81
|
case 'stripe_connect':
|