ordering-ui-react-native 0.16.47-release → 0.16.48-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.
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useState, useRef } from 'react';
2
- import { View, Pressable, StyleSheet, ScrollView, RefreshControl, Linking, Platform, TextInput } from 'react-native';
3
- import { useLanguage, useUtils, useToast, ToastType, OrderListGroups, useConfig } from 'ordering-components/native';
2
+ import { View, Pressable, StyleSheet, ScrollView, RefreshControl, Platform } from 'react-native';
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';
6
6
  import FeatherIcon from 'react-native-vector-icons/Feather';
@@ -20,7 +20,6 @@ import {
20
20
  IconWrapper,
21
21
  ModalContainer,
22
22
  ModalTitle,
23
- FilterBtnWrapper,
24
23
  TabPressable,
25
24
  OrderStatus,
26
25
  SlaOption,
@@ -34,42 +33,17 @@ import {
34
33
  ItemContent,
35
34
  TimerInputWrapper,
36
35
  OverLine,
37
- Actions,
38
36
  InputContainer
39
37
  } from './styles';
40
38
  import { PreviousOrders } from '../PreviousOrders';
41
39
  import { OrdersOptionParams } from '../../types';
42
40
 
43
- import { TouchableOpacity } from 'react-native-gesture-handler';
44
- import GestureRecognizer from 'react-native-swipe-gestures';
45
- import ODropDown from '../shared/ODropDown';
46
- import { OrdersOptionStatus } from '../OrdersOptionStatus'
47
41
  import { OrdersOptionCity } from '../OrdersOptionCity';
48
42
  import { OrdersOptionBusiness } from '../OrdersOptionBusiness';
49
43
  import { OrdersOptionDelivery } from '../OrdersOptionDelivery';
50
44
  import { OrdersOptionPaymethod } from '../OrdersOptionPaymethod';
51
45
  import { OrdersOptionDriver } from '../OrdersOptionDriver';
52
46
  import { OrdersOptionDate } from '../OrdersOptionDate';
53
- import { GestureEvent, GestureDetector } from 'react-native-gesture-handler'
54
- const tabsList: any = {
55
- pending: 1,
56
- inProgress: 2,
57
- completed: 3,
58
- cancelled: 4
59
- };
60
-
61
- const tabsListText: any = {
62
- 1: 'pending',
63
- 2: 'inProgress',
64
- 3: 'completed',
65
- 4: 'cancelled'
66
- };
67
-
68
- const swipeConfig = {
69
- velocityThreshold: 0.3,
70
- directionalOffsetThreshold: 80
71
- };
72
-
73
47
  const { useDeviceOrientation, PORTRAIT } = DeviceOrientationMethods
74
48
 
75
49
  const OrdersOptionUI = (props: OrdersOptionParams) => {
@@ -81,10 +55,10 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
81
55
  ordersGroup,
82
56
  setOrdersGroup,
83
57
  orderStatus,
58
+ ordersFormatted,
84
59
  loadOrders,
85
60
  loadMoreOrders,
86
61
  onNavigationRedirect,
87
- filtered,
88
62
  onFiltered,
89
63
  handleClickOrder,
90
64
  isBusinessApp,
@@ -92,7 +66,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
92
66
  logisticOrders,
93
67
  loadLogisticOrders,
94
68
  isLogisticActivated,
95
- isAlsea
69
+ isAlsea,
70
+ handleChangeOrderStatus,
71
+ handleSendCustomerReview
96
72
  } = props;
97
73
 
98
74
  const defaultSearchList = {
@@ -122,7 +98,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
122
98
  const [slaSettingTime, setSlaSettingTime] = useState(6000)
123
99
  const [currentDeliveryType, setCurrentDeliveryType] = useState('Delivery')
124
100
  const [search, setSearch] = useState(defaultSearchList)
125
- const [selectedTabStatus, setSelectedTabStatus] = useState([])
101
+ const [selectedTabStatus, setSelectedTabStatus] = useState<any>([])
126
102
  const [hour, setHour] = useState(0)
127
103
  const [minute, setMinute] = useState(0)
128
104
  const [openedSelect, setOpenedSelect] = useState('')
@@ -346,26 +322,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
346
322
  })
347
323
  }
348
324
 
349
- const onSwipeLeft = () => {
350
- let currentTab = tabsList[currentTabSelected]
351
- currentTab = currentTab >= 4 ? null : currentTab + 1
352
-
353
- if (!currentTab) return
354
-
355
- const nextTab = tabsListText[currentTab]
356
- nextTab && setCurrentTabSelected(nextTab)
357
- }
358
-
359
- const onSwipeRight = () => {
360
- let currentTab = tabsList[currentTabSelected]
361
- currentTab = currentTab <= 1 ? null : currentTab - 1
362
-
363
- if (!currentTab) return
364
-
365
- const nextTab = tabsListText[currentTab]
366
- nextTab && setCurrentTabSelected(nextTab)
367
- }
368
-
369
325
  const calculateDate = (type: any, from: any, to: any) => {
370
326
  switch (type) {
371
327
  case 'today':
@@ -419,14 +375,8 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
419
375
  useEffect(() => {
420
376
  setSelectedTabStatus(deliveryStatus)
421
377
  }, [])
422
-
378
+
423
379
  return (
424
- // <GestureRecognizer
425
- // onSwipeLeft={onSwipeLeft}
426
- // onSwipeRight={onSwipeRight}
427
- // config={swipeConfig}
428
- // style={{ flex: 1 }}
429
- // >
430
380
  <>
431
381
  <View style={styles.header}>
432
382
  <OText style={styles.title}>{t('MY_ORDERS', 'My orders')}</OText>
@@ -635,12 +585,18 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
635
585
  currentTabSelected !== 'logisticOrders' &&
636
586
  (
637
587
  <PreviousOrders
638
- orders={currentOrdersGroup?.orders}
588
+ orders={ordersFormatted}
589
+ navigation={props.navigation}
639
590
  onNavigationRedirect={onNavigationRedirect}
640
591
  getOrderStatus={getOrderStatus}
641
592
  handleClickOrder={handleClickOrder}
642
593
  slaSettingTime={slaSettingTime}
643
594
  currentTabSelected={currentTabSelected}
595
+ appTitle={props.orderDetailsProps?.appTitle}
596
+ actions={props.orderDetailsProps?.actions}
597
+ orderTitle={props.orderDetailsProps?.orderTitle}
598
+ handleChangeOrderStatus={handleChangeOrderStatus}
599
+ handleSendCustomerReview={handleSendCustomerReview}
644
600
  />
645
601
  )}
646
602
  {!logisticOrders?.error?.length &&
@@ -730,7 +686,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
730
686
  )}
731
687
  </ScrollView>
732
688
  </View>
733
- {/* </GestureRecognizer> */}
734
689
 
735
690
  {isBusinessApp && (
736
691
  <NewOrderNotification isBusinessApp={isBusinessApp} />
@@ -884,7 +839,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
884
839
  </ScrollView>
885
840
  </FiltersTab>
886
841
  <DeliveryStatusWrapper>
887
- {selectedTabStatus && selectedTabStatus.length > 0 && selectedTabStatus.map((item, i) => (
842
+ {selectedTabStatus && selectedTabStatus.length > 0 && selectedTabStatus.map((item: any, i: number) => (
888
843
  <StatusBlock
889
844
  key={i}
890
845
  item={item}
@@ -0,0 +1,250 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Platform, PlatformIOSStatic, StyleSheet, TouchableOpacity, View } from 'react-native';
3
+ import DeviceInfo from 'react-native-device-info';
4
+ import { useTheme } from 'styled-components/native';
5
+ import { useLanguage, useUtils, useConfig } from 'ordering-components/native';
6
+ import EntypoIcon from 'react-native-vector-icons/Entypo'
7
+ import FastImage from 'react-native-fast-image'
8
+ import moment from 'moment'
9
+
10
+ import {
11
+ Card,
12
+ Logo,
13
+ Information,
14
+ MyOrderOptions,
15
+ NotificationIcon,
16
+ Timestatus
17
+ } from './styles'
18
+
19
+ import { OText } from '../shared';
20
+ import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
21
+
22
+ const { useDeviceOrientation, PORTRAIT } = DeviceOrientationMethods
23
+
24
+ export const OrderItem = (props: any) => {
25
+ const {
26
+ order,
27
+ _order,
28
+ isLogisticOrder,
29
+ currentTabSelected,
30
+ getOrderStatus,
31
+ handlePressOrder
32
+ } = props
33
+
34
+ const theme = useTheme()
35
+ const [, t] = useLanguage()
36
+ const [configState] = useConfig()
37
+ const [{ parseDate, optimizeImage }] = useUtils();
38
+ const [orientationState] = useDeviceOrientation();
39
+
40
+ const [allowColumns, setAllowColumns] = useState({
41
+ timer: configState?.configs?.order_deadlines_enabled?.value === '1',
42
+ slaBar: configState?.configs?.order_deadlines_enabled?.value === '1',
43
+ })
44
+
45
+ const IS_PORTRAIT = orientationState.orientation === PORTRAIT
46
+ const platformIOS = Platform as PlatformIOSStatic
47
+
48
+ const isIpad = platformIOS.isPad
49
+ const isTablet = DeviceInfo.isTablet();
50
+
51
+ const styles = StyleSheet.create({
52
+ cardButton: {
53
+ flex: 1,
54
+ paddingVertical: (isIpad || isTablet) ? 20 : 0,
55
+ marginBottom: IS_PORTRAIT ? 25 : 0,
56
+ marginLeft: 3,
57
+ },
58
+ icon: {
59
+ borderRadius: 7.6,
60
+ width: 60,
61
+ height: 60
62
+ },
63
+ logo: {
64
+ borderRadius: 10,
65
+ shadowColor: "#0000006e",
66
+ shadowRadius: 10,
67
+ elevation: 15,
68
+ justifyContent: 'center',
69
+ alignItems: 'center',
70
+ marginLeft: 3,
71
+ },
72
+ title: {
73
+ marginBottom: 6,
74
+ fontFamily: 'Poppins',
75
+ fontStyle: 'normal',
76
+ fontWeight: '600',
77
+ fontSize: 16,
78
+ color: theme.colors.textGray,
79
+ },
80
+ date: {
81
+ marginBottom: 6,
82
+ fontFamily: 'Poppins',
83
+ fontStyle: 'normal',
84
+ fontWeight: 'normal',
85
+ fontSize: 12,
86
+ },
87
+ orderType: {
88
+ fontSize: 12,
89
+ fontFamily: 'Poppins',
90
+ fontStyle: 'normal',
91
+ fontWeight: 'normal',
92
+ color: theme.colors.orderTypeColor,
93
+ },
94
+ });
95
+
96
+ const getDelayMinutes = (order: any) => {
97
+ const offset = 300
98
+ const cdtToutc = moment(order?.delivery_datetime).add(offset, 'minutes').format('YYYY-MM-DD HH:mm:ss')
99
+ const _delivery = order?.delivery_datetime_utc
100
+ ? parseDate(order?.delivery_datetime_utc, { outputFormat: 'YYYY-MM-DD hh:mm A' })
101
+ : parseDate(cdtToutc, { outputFormat: 'YYYY-MM-DD hh:mm A' })
102
+ const _eta = order?.eta_time
103
+ const diffTimeAsSeconds = moment(_delivery, 'YYYY-MM-DD hh:mm A').add(_eta, 'minutes').diff(moment().utc(), 'seconds')
104
+ return Math.ceil(diffTimeAsSeconds / 60)
105
+ }
106
+
107
+ const displayDelayedTime = (order: any) => {
108
+ let tagetedMin = getDelayMinutes(order)
109
+ // get day, hour and minutes
110
+ const sign = tagetedMin >= 0 ? '' : '- '
111
+ tagetedMin = Math.abs(tagetedMin)
112
+ let day: string | number = Math.floor(tagetedMin / 1440)
113
+ const restMinOfTargetedMin = tagetedMin - 1440 * day
114
+ let restHours: string | number = Math.floor(restMinOfTargetedMin / 60)
115
+ let restMins: string | number = restMinOfTargetedMin - 60 * restHours
116
+ // make standard time format
117
+ day = day === 0 ? '' : day + 'day '
118
+ restHours = restHours < 10 ? '0' + restHours : restHours
119
+ restMins = restMins < 10 ? '0' + restMins : restMins
120
+
121
+ const finalTaget = sign + day + restHours + ':' + restMins
122
+ return finalTaget
123
+ }
124
+
125
+ const getStatusClassName = (minutes: number) => {
126
+ if (isNaN(Number(minutes))) return 'in_time'
127
+ const delayTime = configState?.configs?.order_deadlines_delayed_time?.value
128
+ return minutes > 0 ? 'in_time' : Math.abs(minutes) <= delayTime ? 'at_risk' : 'delayed'
129
+ }
130
+
131
+ useEffect(() => {
132
+ const slaSettings = configState?.configs?.order_deadlines_enabled?.value === '1'
133
+ setAllowColumns({
134
+ ...allowColumns,
135
+ timer: slaSettings,
136
+ slaBar: slaSettings
137
+ })
138
+ }, [configState.loading])
139
+
140
+ return (
141
+ <TouchableOpacity
142
+ activeOpacity={1}
143
+ disabled={order?.locked && isLogisticOrder}
144
+ style={styles.cardButton}
145
+ onPress={() => handlePressOrder({ ...order, logistic_order_id: _order?.id })}
146
+ >
147
+ <Card key={order.id}>
148
+ {allowColumns?.slaBar && (
149
+ <Timestatus
150
+ style={{
151
+ backgroundColor: getStatusClassName(getDelayMinutes(order)) === 'in_time'
152
+ ? '#00D27A'
153
+ : getStatusClassName(getDelayMinutes(order)) === 'at_risk'
154
+ ? '#FFC700'
155
+ : getStatusClassName(getDelayMinutes(order)) === 'delayed'
156
+ ? '#E63757'
157
+ : ''
158
+ }}
159
+ />
160
+ )}
161
+ <Logo style={styles.logo}>
162
+ <FastImage
163
+ style={styles.icon}
164
+ source={order.business?.logo ? {
165
+ uri: optimizeImage(order.business?.logo, 'h_100,c_limit'),
166
+ priority: FastImage.priority.normal,
167
+ } : theme?.images?.dummies?.businessLogo}
168
+ resizeMode={FastImage.resizeMode.cover}
169
+ />
170
+ </Logo>
171
+ <Information>
172
+ {!!order?.order_group_id && (
173
+ <OText>
174
+ <OText>{(t('INVOICE_GROUP_NO', 'Group No.') + order?.order_group_id)}</OText>
175
+ </OText>
176
+ )}
177
+ {!!order.business?.name && (
178
+ <OText numberOfLines={1} style={styles.title}>
179
+ {order.business?.name}
180
+ </OText>
181
+ )}
182
+ {!!order?.showNotification && (
183
+ <NotificationIcon>
184
+ <EntypoIcon
185
+ name="dot-single"
186
+ size={32}
187
+ color={theme.colors.primary}
188
+ />
189
+ </NotificationIcon>
190
+ )}
191
+ <View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
192
+ <OText
193
+ style={styles.date}
194
+ color={theme.colors.unselectText}
195
+ numberOfLines={1}
196
+ adjustsFontSizeToFit
197
+ >
198
+ {(order?.order_group_id && order?.order_group && isLogisticOrder
199
+ ? `${order?.order_group?.orders?.length} ${t('ORDERS', 'Orders')}`
200
+ : (t('NO', 'Order No.') + order.id)
201
+ ) + ' · '}
202
+ {order?.delivery_datetime_utc
203
+ ? parseDate(order?.delivery_datetime_utc, { outputFormat: 'MM/DD/YY · HH:mm a' })
204
+ : parseDate(order?.delivery_datetime, { utc: false })}
205
+ </OText>
206
+ {((currentTabSelected === 'pending' || currentTabSelected === 'inProgress') && allowColumns?.timer) && (
207
+ <>
208
+ <OText> · </OText>
209
+ <OText
210
+ style={styles.date}
211
+ color={
212
+ getStatusClassName(getDelayMinutes(order)) === 'in_time'
213
+ ? '#00D27A'
214
+ : getStatusClassName(getDelayMinutes(order)) === 'at_risk'
215
+ ? '#FFC700'
216
+ : getStatusClassName(getDelayMinutes(order)) === 'delayed'
217
+ ? '#E63757'
218
+ : ''}
219
+ >
220
+ {displayDelayedTime(order)}
221
+ </OText>
222
+ </>
223
+ )}
224
+ </View>
225
+ {!isLogisticOrder && (
226
+ <MyOrderOptions>
227
+ <OText
228
+ style={styles.orderType}
229
+ mRight={5}
230
+ numberOfLines={1}
231
+ adjustsFontSizeToFit
232
+ >
233
+ {order.delivery_type === 1
234
+ ? t('DELIVERY', 'Delivery')
235
+ : order.delivery_type === 2
236
+ ? t('PICKUP', 'Pickup')
237
+ : order.delivery_type === 3
238
+ ? t('EAT_IN', 'Eat in')
239
+ : order.delivery_type === 4
240
+ ? t('CURBSIDE', 'Curbside')
241
+ : t('DRIVER_THRU', 'Driver thru')}
242
+ {` · ${getOrderStatus(order.status)}`}
243
+ </OText>
244
+ </MyOrderOptions>
245
+ )}
246
+ </Information>
247
+ </Card>
248
+ </TouchableOpacity>
249
+ )
250
+ }
@@ -0,0 +1,115 @@
1
+ import React, { useState } from 'react'
2
+ import { Animated, StyleSheet, View } from 'react-native'
3
+ import { useTheme } from 'styled-components/native';
4
+ import { useLanguage, useUtils } from 'ordering-components/native'
5
+ import FastImage from 'react-native-fast-image'
6
+ import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
7
+
8
+ import {
9
+ AccordionSection,
10
+ Accordion,
11
+ ContentInfo,
12
+ AccordionContent,
13
+ ProductOptionsList
14
+ } from './styles'
15
+
16
+ import { OText } from '../shared';
17
+
18
+ export const OrdersGroupedItem = (props: any) => {
19
+ const { groupId, orders } = props
20
+
21
+ const theme = useTheme()
22
+ const [, t] = useLanguage()
23
+ const [{ parseDate }] = useUtils();
24
+ const [isActive, setActiveState] = useState(false)
25
+
26
+ const styles = StyleSheet.create({
27
+ productImage: {
28
+ borderRadius: 7.6,
29
+ width: 60,
30
+ height: 60
31
+ },
32
+ logo: {
33
+ borderRadius: 10,
34
+ shadowColor: "#0000006e",
35
+ shadowRadius: 10,
36
+ elevation: 15,
37
+ justifyContent: 'center',
38
+ alignItems: 'center',
39
+ marginLeft: 3,
40
+ height: 65,
41
+ width: 65
42
+ },
43
+ title: {
44
+ marginBottom: 2,
45
+ fontWeight: '600',
46
+ fontSize: 16,
47
+ color: theme.colors.textGray,
48
+ },
49
+ orderlength: {
50
+ marginBottom: 2,
51
+ fontSize: 12,
52
+ },
53
+ })
54
+
55
+ return (
56
+ <AccordionSection>
57
+ <Accordion
58
+ activeOpacity={1}
59
+ onPress={() => setActiveState(!isActive)}
60
+ >
61
+ <View style={{ flexDirection: 'row', alignItems: 'flex-start' }}>
62
+ <ContentInfo>
63
+ <View style={styles.logo}>
64
+ <FastImage
65
+ style={styles.productImage}
66
+ source={theme.images.general.ordersGroup}
67
+ resizeMode={FastImage.resizeMode.cover}
68
+ />
69
+ </View>
70
+ <View style={{ flex: 1, marginLeft: 5, flexDirection: 'column' }}>
71
+ <View>
72
+ <OText numberOfLines={1} style={styles.title}>
73
+ {t('GROUP_NRO', 'Group No.')}{groupId}
74
+ </OText>
75
+ </View>
76
+ <OText
77
+ style={styles.orderlength}
78
+ color={theme.colors.unselectText}
79
+ numberOfLines={1}
80
+ adjustsFontSizeToFit
81
+ >
82
+ {orders.length}{' '}{t('ORDERS', 'Orders')}
83
+ </OText>
84
+ <OText
85
+ style={styles.orderlength}
86
+ color={theme.colors.unselectText}
87
+ numberOfLines={1}
88
+ adjustsFontSizeToFit
89
+ >
90
+ {orders[0]?.delivery_datetime_utc
91
+ ? parseDate(orders[0]?.delivery_datetime_utc, { outputFormat: 'MM/DD/YY · HH:mm a' })
92
+ : parseDate(orders[0]?.delivery_datetime, { utc: false })}
93
+ </OText>
94
+ </View>
95
+ <View style={{ display: 'flex', flexDirection: 'column', flex: 1, alignItems: 'flex-end', maxWidth: 100 }}>
96
+ <View style={{ flexDirection: 'row' }}>
97
+ <MaterialCommunityIcon name={isActive ? 'chevron-up' : 'chevron-down'} size={18} />
98
+ </View>
99
+ </View>
100
+ </ContentInfo>
101
+ </View>
102
+ </Accordion>
103
+
104
+ <View style={{ display: isActive ? 'flex' : 'none' }}>
105
+ <Animated.View>
106
+ <AccordionContent>
107
+ <ProductOptionsList>
108
+ {props.children}
109
+ </ProductOptionsList>
110
+ </AccordionContent>
111
+ </Animated.View>
112
+ </View>
113
+ </AccordionSection>
114
+ )
115
+ }