ordering-ui-react-native 0.18.1 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.18.1",
3
+ "version": "0.18.3",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -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 { showLocation } from 'react-native-map-link';
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={() => showLocation({
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 && (
@@ -29,6 +29,10 @@ import { ReviewCustomer } from '../ReviewCustomer'
29
29
 
30
30
  import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons'
31
31
 
32
+ import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
33
+
34
+ const { useDeviceOrientation } = DeviceOrientationMethods
35
+
32
36
  interface OrderContent {
33
37
  order: any,
34
38
  logisticOrderStatus?: Array<number>,
@@ -39,13 +43,15 @@ interface OrderContent {
39
43
  export const OrderContentComponent = (props: OrderContent) => {
40
44
  const [, t] = useLanguage();
41
45
  const theme = useTheme()
42
- const [{user}] = useSession()
43
- console.log(user)
46
+ const [{ user }] = useSession()
44
47
  const { order, logisticOrderStatus, isOrderGroup, lastOrder } = props;
45
48
  const [{ parsePrice, parseNumber }] = useUtils();
46
49
  const [{ configs }] = useConfig();
50
+ const [orientationState] = useDeviceOrientation();
47
51
  const distanceUnit = configs?.distance_unit?.value
48
52
 
53
+ const WIDTH_SCREEN = orientationState?.dimensions?.width
54
+
49
55
  const [openReviewModal, setOpenReviewModal] = useState(false)
50
56
 
51
57
  const [isReadMore, setIsReadMore] = useState(false)
@@ -103,8 +109,8 @@ export const OrderContentComponent = (props: OrderContent) => {
103
109
  }
104
110
 
105
111
  const onTextLayout = useCallback((e: any) => {
106
- setLengthMore(e.nativeEvent.lines.length >= 3); //to check the text is more than 2 lines or not
107
- },[]);
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
+ }, []);
108
114
 
109
115
  return (
110
116
  <OrderContent isOrderGroup={isOrderGroup} lastOrder={lastOrder}>
@@ -9,12 +9,15 @@ import {
9
9
 
10
10
  //Components
11
11
  import {
12
+ OIcon,
12
13
  OIconButton,
13
14
  OText,
14
15
  } from '../shared'
15
16
 
16
17
  import { useTheme } from 'styled-components/native';
17
- import { StyleSheet, View } from 'react-native';
18
+ import { StyleSheet, TouchableOpacity, View } from 'react-native';
19
+ import SimpleLineIcons from 'react-native-vector-icons/SimpleLineIcons'
20
+ import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'
18
21
 
19
22
  import {
20
23
  useLanguage,
@@ -54,6 +57,19 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
54
57
  height: 40,
55
58
  padding: 10,
56
59
  alignItems: 'flex-end',
60
+ color: theme.colors.textGray,
61
+ },
62
+ btnBackArrow: {
63
+ borderWidth: 0,
64
+ width: 32,
65
+ height: 32,
66
+ tintColor: theme.colors.textGray,
67
+ backgroundColor: theme.colors.clear,
68
+ borderColor: theme.colors.clear,
69
+ shadowColor: theme.colors.clear,
70
+ paddingLeft: 0,
71
+ paddingRight: 0,
72
+ marginTop: 10
57
73
  },
58
74
  })
59
75
 
@@ -108,42 +124,30 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
108
124
  <>
109
125
  {!props.isCustomView && (
110
126
  <Header>
111
- <OIconButton
112
- icon={theme.images.general.arrow_left}
113
- iconStyle={{ width: 20, height: 20 }}
114
- borderColor={theme.colors.clear}
115
- style={{ ...styles.icons, justifyContent: 'flex-end' }}
116
- onClick={() => handleArrowBack()}
117
- />
118
-
127
+ <TouchableOpacity onPress={() => handleArrowBack()} style={styles.btnBackArrow}>
128
+ <OIcon src={theme.images.general.arrow_left} color={theme.colors.textGray} />
129
+ </TouchableOpacity>
119
130
  {(!order?.isLogistic || (!logisticOrderStatus?.includes(order?.status) && !order?.order_group)) && (
120
131
  <Actions>
121
132
  {getOrderStatus(order?.status, t)?.value !==
122
133
  t('PENDING', 'Pending') && (
123
134
  <>
124
- <OIconButton
125
- icon={theme.images.general.copy}
126
- iconStyle={{
127
- width: 20,
128
- height: 25,
129
- top: 2,
130
- tintColor: theme.colors.backArrow,
131
- }}
132
- borderColor={theme.colors.clear}
133
- style={styles.icons}
134
- onClick={() => handleCopyClipboard?.()}
135
- />
136
- <OIconButton
137
- icon={theme.images.general.print}
138
- iconStyle={{
139
- width: 25,
140
- height: 22,
141
- tintColor: theme.colors.backArrow,
142
- }}
143
- borderColor={theme.colors.clear}
144
- style={styles.icons}
145
- onClick={() => handleViewSummaryOrder?.()}
146
- />
135
+ <TouchableOpacity onPress={() => handleCopyClipboard?.()}>
136
+ <MaterialCommunityIcons
137
+ name='content-copy'
138
+ color={theme.colors.textGray}
139
+ size={20}
140
+ style={styles.icons}
141
+ />
142
+ </TouchableOpacity>
143
+ <TouchableOpacity onPress={() => handleViewSummaryOrder?.()}>
144
+ <SimpleLineIcons
145
+ name='printer'
146
+ color={theme.colors.textGray}
147
+ size={20}
148
+ style={styles.icons}
149
+ />
150
+ </TouchableOpacity>
147
151
  </>
148
152
  )}
149
153
  <OIconButton
@@ -151,7 +155,7 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
151
155
  iconStyle={{
152
156
  width: 20,
153
157
  height: 20,
154
- tintColor: theme.colors.backArrow,
158
+ tintColor: theme.colors.textGray,
155
159
  }}
156
160
  borderColor={theme.colors.clear}
157
161
  style={styles.icons}
@@ -163,7 +167,7 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
163
167
  iconStyle={{
164
168
  width: 20,
165
169
  height: 20,
166
- tintColor: theme.colors.backArrow,
170
+ tintColor: theme.colors.textGray,
167
171
  }}
168
172
  borderColor={theme.colors.clear}
169
173
  style={styles.icons}
@@ -193,29 +197,22 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
193
197
  {getOrderStatus(order?.status, t)?.value !==
194
198
  t('PENDING', 'Pending') && (
195
199
  <>
196
- <OIconButton
197
- icon={theme.images.general.copy}
198
- iconStyle={{
199
- width: 20,
200
- height: 25,
201
- top: 2,
202
- tintColor: theme.colors.backArrow,
203
- }}
204
- borderColor={theme.colors.clear}
205
- style={styles.icons}
206
- onClick={() => handleCopyClipboard?.()}
207
- />
208
- <OIconButton
209
- icon={theme.images.general.print}
210
- iconStyle={{
211
- width: 25,
212
- height: 22,
213
- tintColor: theme.colors.backArrow,
214
- }}
215
- borderColor={theme.colors.clear}
216
- style={styles.icons}
217
- onClick={() => handleViewSummaryOrder?.()}
218
- />
200
+ <TouchableOpacity onPress={() => handleCopyClipboard?.()}>
201
+ <MaterialCommunityIcons
202
+ name='content-copy'
203
+ color={theme.colors.textGray}
204
+ size={20}
205
+ style={styles.icons}
206
+ />
207
+ </TouchableOpacity>
208
+ <TouchableOpacity onPress={() => handleViewSummaryOrder?.()}>
209
+ <SimpleLineIcons
210
+ name='printer'
211
+ color={theme.colors.textGray}
212
+ size={20}
213
+ style={styles.icons}
214
+ />
215
+ </TouchableOpacity>
219
216
  </>
220
217
  )}
221
218
  <OIconButton
@@ -223,7 +220,7 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
223
220
  iconStyle={{
224
221
  width: 20,
225
222
  height: 20,
226
- tintColor: theme.colors.backArrow,
223
+ tintColor: theme.colors.textGray,
227
224
  }}
228
225
  borderColor={theme.colors.clear}
229
226
  style={styles.icons}
@@ -235,7 +232,7 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
235
232
  iconStyle={{
236
233
  width: 20,
237
234
  height: 20,
238
- tintColor: theme.colors.backArrow,
235
+ tintColor: theme.colors.textGray,
239
236
  }}
240
237
  borderColor={theme.colors.clear}
241
238
  style={styles.icons}
@@ -1,7 +1,7 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
3
3
  import { Chat } from '../Chat';
4
- import { StyleSheet, View, BackHandler } from 'react-native';
4
+ import { StyleSheet, View, BackHandler, TouchableOpacity } from 'react-native';
5
5
  import {
6
6
  useLanguage,
7
7
  OrderDetails as OrderDetailsController,
@@ -9,7 +9,7 @@ import {
9
9
  } from 'ordering-components/native';
10
10
  import { useUtils } from 'ordering-components/native';
11
11
 
12
- import { OIcon, OIconButton, OText } from '../shared';
12
+ import { OIcon, OText } from '../shared';
13
13
  import { OrderDetailsParams } from '../../types';
14
14
  import { USER_TYPE } from '../../config/constants';
15
15
  import { useTheme } from 'styled-components/native';
@@ -146,13 +146,6 @@ export const OrderMessageUI = (props: OrderDetailsParams) => {
146
146
  shadowRadius: 3.84,
147
147
  elevation: 3,
148
148
  },
149
- cancelBtn: {
150
- marginRight: 5,
151
- zIndex: 10000,
152
- height: 30,
153
- width: 20,
154
- justifyContent: 'flex-end',
155
- },
156
149
  modalText: {
157
150
  fontFamily: 'Poppins',
158
151
  fontStyle: 'normal',
@@ -161,6 +154,18 @@ export const OrderMessageUI = (props: OrderDetailsParams) => {
161
154
  textAlign: 'center',
162
155
  zIndex: 10,
163
156
  },
157
+ btnBackArrow: {
158
+ borderWidth: 0,
159
+ width: 32,
160
+ height: 32,
161
+ tintColor: theme.colors.textGray,
162
+ backgroundColor: theme.colors.clear,
163
+ borderColor: theme.colors.clear,
164
+ shadowColor: theme.colors.clear,
165
+ paddingLeft: 0,
166
+ paddingRight: 0,
167
+ marginTop: 10
168
+ },
164
169
  });
165
170
 
166
171
  return (
@@ -260,13 +265,9 @@ export const OrderMessageUI = (props: OrderDetailsParams) => {
260
265
  <>
261
266
  <View style={styles.titleSection}>
262
267
  <View style={styles.titleGroups}>
263
- <OIconButton
264
- icon={theme.images.general.arrow_left}
265
- iconStyle={{ width: 23, height: 23 }}
266
- borderColor={theme.colors.clear}
267
- style={styles.cancelBtn}
268
- onClick={handleArrowBack}
269
- />
268
+ <TouchableOpacity onPress={() => handleArrowBack()} style={styles.btnBackArrow}>
269
+ <OIcon src={theme.images.general.arrow_left} color={theme.colors.textGray} />
270
+ </TouchableOpacity>
270
271
 
271
272
  <OText size={16} style={styles.modalText} adjustsFontSizeToFit>
272
273
  {`${t('INVOICE_ORDER_NO', 'Order No.')} ${order?.id}`}
@@ -292,7 +293,7 @@ export const OrderMessageUI = (props: OrderDetailsParams) => {
292
293
  <OIcon
293
294
  url={optimizeImage(
294
295
  order?.customer?.photo ||
295
- theme?.images?.dummies?.customerPhoto,
296
+ theme?.images?.dummies?.customerPhoto,
296
297
  'h_300,c_limit',
297
298
  )}
298
299
  style={styles.titleIcons}
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState, useRef } from 'react';
2
- import { View, Pressable, StyleSheet, ScrollView, RefreshControl, Platform } from 'react-native';
2
+ import { View, Pressable, StyleSheet, ScrollView, RefreshControl, Platform, TouchableOpacity } from 'react-native';
3
3
  import { useLanguage, useUtils, useToast, OrderListGroups, useConfig } from 'ordering-components/native';
4
4
  import SelectDropdown from 'react-native-select-dropdown'
5
5
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
@@ -239,6 +239,19 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
239
239
  overflow: 'hidden',
240
240
  minHeight: 155
241
241
  },
242
+ btnBackArrow: {
243
+ borderWidth: 0,
244
+ width: 32,
245
+ height: 32,
246
+ tintColor: theme.colors.textGray,
247
+ backgroundColor: theme.colors.clear,
248
+ borderColor: theme.colors.clear,
249
+ shadowColor: theme.colors.clear,
250
+ paddingLeft: 0,
251
+ paddingRight: 0,
252
+ marginBottom: 30,
253
+ marginTop: 30
254
+ },
242
255
  rowStyle: {
243
256
  display: 'flex',
244
257
  borderBottomWidth: 0,
@@ -696,20 +709,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
696
709
  <ModalContainer
697
710
  nestedScrollEnabled={true}
698
711
  >
699
- <OIconButton
700
- icon={theme.images.general.arrow_left}
701
- borderColor={theme.colors.clear}
702
- iconColor={theme.colors.backArrow}
703
- iconStyle={{ width: 20, height: 13 }}
704
- style={{
705
- maxWidth: 40,
706
- height: 35,
707
- justifyContent: 'flex-end',
708
- marginBottom: 30,
709
- marginTop: 30
710
- }}
711
- onClick={() => handleClose()}
712
- />
712
+ <TouchableOpacity onPress={() => handleClose()} style={styles.btnBackArrow}>
713
+ <OIcon src={theme.images.general.arrow_left} color={theme.colors.textGray} />
714
+ </TouchableOpacity>
713
715
  {openSearchModal && (
714
716
  <SearchModalContent>
715
717
  <ModalTitle>{t('SEARCH_ORDERS', 'Search orders')}</ModalTitle>
@@ -3,6 +3,10 @@ import { View, Animated, TouchableOpacity } from 'react-native';
3
3
  import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons';
4
4
  import { useUtils, useLanguage } from 'ordering-components/native';
5
5
  import { useTheme } from 'styled-components/native';
6
+ import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
7
+
8
+ const { useDeviceOrientation } = DeviceOrientationMethods
9
+
6
10
  import {
7
11
  Accordion,
8
12
  AccordionSection,
@@ -34,6 +38,8 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
34
38
  const [, t] = useLanguage();
35
39
  const theme = useTheme();
36
40
  const [{ parsePrice }] = useUtils();
41
+ const [orientationState] = useDeviceOrientation();
42
+ const WIDTH_SCREEN = orientationState?.dimensions?.width
37
43
 
38
44
  const [isActive, setActiveState] = useState(false);
39
45
  const [isReadMore, setIsReadMore] = useState(false);
@@ -111,7 +117,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
111
117
  }, []);
112
118
 
113
119
  const onTextLayout = useCallback((e: any) => {
114
- setLengthMore(e.nativeEvent.lines.length >= 3); //to check the text is more than 2 lines or not
120
+ 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
115
121
  },[]);
116
122
 
117
123
  return (
@@ -86,6 +86,18 @@ const ReviewCustomerUI = (props: ReviewCustomerParams) => {
86
86
  marginBottom: 10,
87
87
  backgroundColor: theme.colors.lightGray
88
88
  },
89
+ btnBackArrow: {
90
+ borderWidth: 0,
91
+ width: 32,
92
+ height: 32,
93
+ tintColor: theme.colors.textGray,
94
+ backgroundColor: theme.colors.clear,
95
+ borderColor: theme.colors.clear,
96
+ shadowColor: theme.colors.clear,
97
+ paddingLeft: 0,
98
+ paddingRight: 0,
99
+ marginBottom: 20
100
+ },
89
101
  inputTextArea: {
90
102
  borderColor: theme.colors.lightGray,
91
103
  borderRadius: 8,
@@ -177,18 +189,9 @@ const ReviewCustomerUI = (props: ReviewCustomerParams) => {
177
189
  }}
178
190
  >
179
191
  <View>
180
- <OIconButton
181
- icon={theme.images.general.arrow_left}
182
- borderColor={theme.colors.clear}
183
- iconStyle={{ width: 20, height: 16 }}
184
- style={{
185
- maxWidth: 40,
186
- height: 20,
187
- justifyContent: 'flex-end',
188
- marginBottom: 20,
189
- }}
190
- onClick={() => closeModal()}
191
- />
192
+ <TouchableOpacity onPress={() => closeModal()} style={styles.btnBackArrow}>
193
+ <OIcon src={theme.images.general.arrow_left} color={theme.colors.textGray} />
194
+ </TouchableOpacity>
192
195
  <OText
193
196
  size={20}
194
197
  weight="600"
@@ -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
- <OIconButton
209
- icon={theme.images.general.arrow_left}
210
- iconStyle={{ width: 20, height: 20 }}
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
- isAsap
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
- const selectedMenu = Object.keys(menu).length > 0 ? (menu?.use_business_schedule ? business : menu) : business
256
- const _times = getTimes(selectDate, selectedMenu)
257
- setTimeList(_times)
258
- }, [selectDate, menu])
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={14}
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
  `}
@@ -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 : 2]}
418
+ stickyHeaderIndices={[business?.professionals?.length > 0 ? 3 : 2]}
419
419
  style={{
420
420
  ...styles.mainContainer,
421
421
  marginBottom: currentCart?.products?.length > 0 && categoryState.products.length !== 0 ?
@@ -24,6 +24,7 @@ const DriverTipsUI = (props: any) => {
24
24
  driverTipsOptions,
25
25
  isMulti,
26
26
  cart,
27
+ carts,
27
28
  isDriverTipUseCustom,
28
29
  handlerChangeOption,
29
30
  isFixedPrice
@@ -64,6 +65,10 @@ const DriverTipsUI = (props: any) => {
64
65
  setvalue(val)
65
66
  }
66
67
 
68
+ const multiCartTipsAmmout = carts?.reduce((total: any, cart: any) => {
69
+ return total + parseFloat(cart?.driver_tip || 0)
70
+ }, 0)
71
+
67
72
  return (
68
73
  <DTContainer>
69
74
  <DTLabel>
@@ -138,7 +143,7 @@ const DriverTipsUI = (props: any) => {
138
143
  style={{ marginTop: 10, textAlign: 'center' }}
139
144
  >
140
145
  {t('CURRENT_DRIVER_TIP_AMOUNT', 'Current driver tip amount')}{!isFixedPrice &&
141
- ` (${driverTip}%)`}: {isFixedPrice ? parsePrice(driverTip) : parsePrice(cart?.driver_tip)}
146
+ ` (${driverTip}%)`}: {isFixedPrice ? parsePrice(multiCartTipsAmmout ?? driverTip) : parsePrice(multiCartTipsAmmout ?? cart?.driver_tip)}
142
147
  </OText>
143
148
  )}
144
149
  </DTContainer>
@@ -481,9 +481,9 @@ export const ProductOptionsUI = (props: any) => {
481
481
  : t('LOGIN_SIGNUP', 'Login / Sign Up')
482
482
  }
483
483
  imgRightSrc=""
484
- textStyle={{ color: theme.colors.primary, fontSize: 14 }}
484
+ textStyle={{ color: theme.colors.primary, fontSize: 13, textAlign: 'center' }}
485
485
  style={{
486
- height: 44,
486
+ height: 42,
487
487
  borderColor: theme.colors.primary,
488
488
  backgroundColor: theme.colors.white,
489
489
  paddingLeft: 0,
@@ -498,7 +498,7 @@ export const ProductOptionsUI = (props: any) => {
498
498
  <PlaceholderLine width={60} height={20} />
499
499
  </Placeholder>
500
500
  ) : (
501
- <OText color={theme.colors.primary} size={13}>{t('WITH_GUEST_USER', 'With Guest user')}</OText>
501
+ <OText color={theme.colors.primary} size={13} style={{ textAlign: 'center' }}>{t('WITH_GUEST_USER', 'With Guest user')}</OText>
502
502
  )}
503
503
  </TouchableOpacity>
504
504
  )}
@@ -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;