ordering-ui-react-native 0.18.2 → 0.18.3
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/DriverMap/index.tsx +16 -5
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +3 -3
- package/themes/business/src/components/shared/OModal.tsx +16 -9
- package/themes/original/src/components/BusinessPreorder/index.tsx +96 -15
- package/themes/original/src/components/BusinessPreorder/styles.tsx +14 -0
- package/themes/original/src/types/index.tsx +3 -0
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ import Icon from 'react-native-vector-icons/FontAwesome5';
|
|
|
12
12
|
import { useTheme } from 'styled-components/native';
|
|
13
13
|
import { useLocation } from '../../hooks/useLocation';
|
|
14
14
|
import { FloatingButton } from '../FloatingButton';
|
|
15
|
-
import {
|
|
15
|
+
import { Popup } from 'react-native-map-link';
|
|
16
16
|
import { transformDistance } from '../../utils';
|
|
17
17
|
|
|
18
18
|
export const DriverMap = (props: GoogleMapsParams) => {
|
|
@@ -48,6 +48,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
48
48
|
const [distancesFromTwoPlacesKm, setDistancesFromTwoPlacesKm] = useState(0);
|
|
49
49
|
const [isMin, setIsMin] = useState(false);
|
|
50
50
|
const [{ parseDate }] = useUtils();
|
|
51
|
+
const [popUp, setPopUp] = useState<boolean>(false);
|
|
51
52
|
const mapErrors: any = {
|
|
52
53
|
ERROR_NOT_FOUND_ADDRESS: "Sorry, we couldn't find an address",
|
|
53
54
|
ERROR_MAX_LIMIT_LOCATION_TO: 'Sorry, You can only set the position to',
|
|
@@ -478,7 +479,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
478
479
|
style={styles.arrowDistance}
|
|
479
480
|
/>
|
|
480
481
|
<OText size={12} numberOfLines={3}>
|
|
481
|
-
{`${transformDistance(distancesFromTwoPlacesKm, distanceUnit)} ${t(distanceUnit.toUpperCase(), distanceUnit)}`}
|
|
482
|
+
{`${transformDistance(distancesFromTwoPlacesKm, distanceUnit)} ${t(distanceUnit.toUpperCase(), distanceUnit)}`}
|
|
482
483
|
</OText>
|
|
483
484
|
|
|
484
485
|
</View>
|
|
@@ -501,7 +502,18 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
501
502
|
imgRightSrc=''
|
|
502
503
|
textStyle={{ color: theme.colors.white }}
|
|
503
504
|
style={styles.showButton}
|
|
504
|
-
onClick={() =>
|
|
505
|
+
onClick={() => setPopUp(true)}
|
|
506
|
+
text={t('SHOW_IN_OTHER_MAPS', 'Show in other maps')}
|
|
507
|
+
/>
|
|
508
|
+
<Popup
|
|
509
|
+
isVisible={popUp}
|
|
510
|
+
onCancelPressed={() => setPopUp(false)}
|
|
511
|
+
onAppPressed={() => setPopUp(false)}
|
|
512
|
+
onBackButtonPressed={() => setPopUp(false)}
|
|
513
|
+
modalProps={{
|
|
514
|
+
animationIn: 'slideInUp'
|
|
515
|
+
}}
|
|
516
|
+
options={{
|
|
505
517
|
latitude: destination.latitude,
|
|
506
518
|
longitude: destination.longitude,
|
|
507
519
|
sourceLatitude: userLocation.latitude,
|
|
@@ -510,8 +522,7 @@ export const DriverMap = (props: GoogleMapsParams) => {
|
|
|
510
522
|
dialogTitle: t('SHOW_IN_OTHER_MAPS', 'Show in other maps'),
|
|
511
523
|
dialogMessage: t('WHAT_APP_WOULD_YOU_USE', 'What app would you like to use?'),
|
|
512
524
|
cancelText: t('CANCEL', 'Cancel'),
|
|
513
|
-
}
|
|
514
|
-
text={t('SHOW_IN_OTHER_MAPS', 'Show in other maps')}
|
|
525
|
+
}}
|
|
515
526
|
/>
|
|
516
527
|
</View>
|
|
517
528
|
{showAcceptOrReject && (
|
|
@@ -43,12 +43,12 @@ interface OrderContent {
|
|
|
43
43
|
export const OrderContentComponent = (props: OrderContent) => {
|
|
44
44
|
const [, t] = useLanguage();
|
|
45
45
|
const theme = useTheme()
|
|
46
|
-
const [{user}] = useSession()
|
|
47
|
-
console.log(user)
|
|
46
|
+
const [{ user }] = useSession()
|
|
48
47
|
const { order, logisticOrderStatus, isOrderGroup, lastOrder } = props;
|
|
49
48
|
const [{ parsePrice, parseNumber }] = useUtils();
|
|
50
49
|
const [{ configs }] = useConfig();
|
|
51
50
|
const [orientationState] = useDeviceOrientation();
|
|
51
|
+
const distanceUnit = configs?.distance_unit?.value
|
|
52
52
|
|
|
53
53
|
const WIDTH_SCREEN = orientationState?.dimensions?.width
|
|
54
54
|
|
|
@@ -110,7 +110,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
110
110
|
|
|
111
111
|
const onTextLayout = useCallback((e: any) => {
|
|
112
112
|
setLengthMore((e.nativeEvent.lines.length == 2 && e.nativeEvent.lines[1].width > WIDTH_SCREEN * .76) || e.nativeEvent.lines.length > 2); //to check the text is more than 2 lines or not
|
|
113
|
-
},[]);
|
|
113
|
+
}, []);
|
|
114
114
|
|
|
115
115
|
return (
|
|
116
116
|
<OrderContent isOrderGroup={isOrderGroup} lastOrder={lastOrder}>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Modal, StyleSheet, SafeAreaView, View } from 'react-native';
|
|
2
|
+
import { Modal, StyleSheet, SafeAreaView, View, TouchableOpacity } from 'react-native';
|
|
3
3
|
import Icon from 'react-native-vector-icons/Feather';
|
|
4
4
|
import OIcon from './OIcon';
|
|
5
5
|
import OText from './OText';
|
|
@@ -158,6 +158,18 @@ const OModal = (props: Props): React.ReactElement => {
|
|
|
158
158
|
fontWeight: '600',
|
|
159
159
|
textAlign: 'center',
|
|
160
160
|
},
|
|
161
|
+
btnBackArrow: {
|
|
162
|
+
borderWidth: 0,
|
|
163
|
+
width: 32,
|
|
164
|
+
height: 32,
|
|
165
|
+
tintColor: theme.colors.textGray,
|
|
166
|
+
backgroundColor: theme.colors.clear,
|
|
167
|
+
borderColor: theme.colors.clear,
|
|
168
|
+
shadowColor: theme.colors.clear,
|
|
169
|
+
paddingLeft: 0,
|
|
170
|
+
paddingRight: 0,
|
|
171
|
+
marginTop: 10
|
|
172
|
+
},
|
|
161
173
|
});
|
|
162
174
|
|
|
163
175
|
return (
|
|
@@ -205,14 +217,9 @@ const OModal = (props: Props): React.ReactElement => {
|
|
|
205
217
|
{!customClose && (
|
|
206
218
|
<View style={styles.titleSection}>
|
|
207
219
|
<View style={styles.titleGroups}>
|
|
208
|
-
<
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
borderColor={theme.colors.clear}
|
|
212
|
-
style={styleCloseButton || styles.cancelBtn}
|
|
213
|
-
onClick={onClose}
|
|
214
|
-
/>
|
|
215
|
-
|
|
220
|
+
<TouchableOpacity onPress={() => onClose()} style={styles.btnBackArrow}>
|
|
221
|
+
<OIcon src={theme.images.general.arrow_left} color={theme.colors.textGray} />
|
|
222
|
+
</TouchableOpacity>
|
|
216
223
|
<OText
|
|
217
224
|
size={16}
|
|
218
225
|
style={styles.modalText}
|
|
@@ -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(a || 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
|
}
|
|
@@ -21,6 +21,10 @@ export const OrderTimeWrapper = styled.View`
|
|
|
21
21
|
export const TimeListWrapper = styled.ScrollView`
|
|
22
22
|
margin-top: 30px;
|
|
23
23
|
max-height: 160px;
|
|
24
|
+
${({ cateringPreorder }: any) => cateringPreorder && css`
|
|
25
|
+
max-height: 210px;
|
|
26
|
+
height: 210px;
|
|
27
|
+
`}
|
|
24
28
|
`
|
|
25
29
|
|
|
26
30
|
export const TimeContentWrapper = styled.View`
|
|
@@ -38,6 +42,16 @@ export const TimeItem = styled.View`
|
|
|
38
42
|
justify-content: center;
|
|
39
43
|
align-items: center;
|
|
40
44
|
margin: 10px 0px;
|
|
45
|
+
${({ cateringPreorder }: any) => cateringPreorder && css`
|
|
46
|
+
background: #fff;
|
|
47
|
+
width: 100%;
|
|
48
|
+
min-width: 100%;
|
|
49
|
+
height: 50px;
|
|
50
|
+
flex-direction: row;
|
|
51
|
+
justify-content: flex-start;
|
|
52
|
+
padding-left: 10px;
|
|
53
|
+
margin: 0;
|
|
54
|
+
`}
|
|
41
55
|
${({ active }: any) => active && css`
|
|
42
56
|
background: #F5F9FF;
|
|
43
57
|
`}
|
|
@@ -570,6 +570,9 @@ export interface BusinessPreorderParams {
|
|
|
570
570
|
goToBack: any;
|
|
571
571
|
business: any;
|
|
572
572
|
handleBusinessClick: (value: any) => {};
|
|
573
|
+
getActualSchedule?: any;
|
|
574
|
+
cateringPreorder?: boolean;
|
|
575
|
+
preorderLeadTime?: number
|
|
573
576
|
}
|
|
574
577
|
export interface BusinessMenuListParams {
|
|
575
578
|
menu: any;
|