ordering-ui-react-native 0.15.42 → 0.15.43

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.15.42",
3
+ "version": "0.15.43",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -77,6 +77,7 @@ const OrdersListManagerUI = (props: OrdersOptionParams) => {
77
77
  const [openSearchModal, setOpenSearchModal] = useState(false)
78
78
  const [openSLASettingModal, setOpenSLASettingModal] = useState(false)
79
79
  const [slaSettingTime, setSlaSettingTime] = useState(6000)
80
+ const [configState] = useConfig()
80
81
  const [currentDeliveryType, setCurrentDeliveryType] = useState('Delivery')
81
82
  const [search, setSearch] = useState(defaultSearchList)
82
83
  const [selectedTabStatus, setSelectedTabStatus] = useState<any>([])
@@ -311,55 +312,57 @@ const OrdersListManagerUI = (props: OrdersOptionParams) => {
311
312
  />
312
313
  </IconWrapper>
313
314
  </View>
314
- <View style={styles.SLAwrapper}>
315
- <View style={{ flex: 0.5 }}>
316
- <OButton
317
- text={t('SLA_SETTING', 'SLA’s Settings')}
318
- textStyle={{ color: theme.colors.backArrow }}
319
- imgRightSrc={null}
320
- style={{
321
- backgroundColor: theme.colors.inputChat,
322
- borderRadius: 7.6,
323
- zIndex: 10,
324
- borderWidth: 0,
325
- minHeight: 40
326
- }}
327
- onClick={onClickSetting}
328
- />
329
- </View>
330
- <View style={{ width: 10, height: '100%' }} />
331
- <View style={{ flex: 0.5, justifyContent: 'center' }}>
332
- <SelectDropdown
333
- defaultButtonText={t('SLA', 'SLA\'s')}
334
- data={preorderTypeList}
335
- onSelect={(selectedItem, index) => {
336
- onFiltered && onFiltered({ ...search, timeStatus: selectedItem?.key })
337
- }}
338
- buttonTextAfterSelection={(selectedItem, index) => {
339
- return selectedItem.name
340
- }}
341
- rowTextForSelection={(item, index) => {
342
- return item.key
343
- }}
344
- buttonStyle={styles.selectOption}
345
- buttonTextStyle={styles.buttonTextStyle}
346
- renderDropdownIcon={isOpened => {
347
- return <FeatherIcon name={isOpened ? 'chevron-up' : 'chevron-down'} color={'#444'} size={18} />;
348
- }}
349
- dropdownStyle={styles.dropdownStyle}
350
- dropdownOverlayColor='transparent'
351
- rowStyle={styles.rowStyle}
352
- renderCustomizedRowChild={(item, index) => {
353
- return (
354
- <SlaOption>
355
- {index !== 0 && <OrderStatus timeState={item?.key} />}
356
- <View><OText size={14} color={'#748194'} >{item?.name}</OText></View>
357
- </SlaOption>
358
- );
359
- }}
360
- />
315
+ {configState?.configs?.order_deadlines_enabled?.value === '1' && (
316
+ <View style={styles.SLAwrapper}>
317
+ <View style={{ flex: 0.5 }}>
318
+ <OButton
319
+ text={t('SLA_SETTING', 'SLA’s Settings')}
320
+ textStyle={{ color: theme.colors.backArrow }}
321
+ imgRightSrc={null}
322
+ style={{
323
+ backgroundColor: theme.colors.inputChat,
324
+ borderRadius: 7.6,
325
+ zIndex: 10,
326
+ borderWidth: 0,
327
+ minHeight: 40
328
+ }}
329
+ onClick={onClickSetting}
330
+ />
331
+ </View>
332
+ <View style={{ width: 10, height: '100%' }} />
333
+ <View style={{ flex: 0.5, justifyContent: 'center' }}>
334
+ <SelectDropdown
335
+ defaultButtonText={t('SLA', 'SLA\'s')}
336
+ data={preorderTypeList}
337
+ onSelect={(selectedItem, index) => {
338
+ onFiltered && onFiltered({ ...search, timeStatus: selectedItem?.key })
339
+ }}
340
+ buttonTextAfterSelection={(selectedItem, index) => {
341
+ return selectedItem.name
342
+ }}
343
+ rowTextForSelection={(item, index) => {
344
+ return item.key
345
+ }}
346
+ buttonStyle={styles.selectOption}
347
+ buttonTextStyle={styles.buttonTextStyle}
348
+ renderDropdownIcon={isOpened => {
349
+ return <FeatherIcon name={isOpened ? 'chevron-up' : 'chevron-down'} color={'#444'} size={18} />;
350
+ }}
351
+ dropdownStyle={styles.dropdownStyle}
352
+ dropdownOverlayColor='transparent'
353
+ rowStyle={styles.rowStyle}
354
+ renderCustomizedRowChild={(item, index) => {
355
+ return (
356
+ <SlaOption>
357
+ {index !== 0 && <OrderStatus timeState={item?.key} />}
358
+ <View><OText size={14} color={'#748194'} >{item?.name}</OText></View>
359
+ </SlaOption>
360
+ );
361
+ }}
362
+ />
363
+ </View>
361
364
  </View>
362
- </View>
365
+ )}
363
366
 
364
367
  <Sides>
365
368
  <LeftSide>
@@ -110,6 +110,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
110
110
  const theme = useTheme();
111
111
  const [, t] = useLanguage();
112
112
  const [{ parseDate }] = useUtils()
113
+ const [configState] = useConfig()
113
114
  const [orientationState] = useDeviceOrientation();
114
115
  const [, { showToast }] = useToast();
115
116
  const [openSearchModal, setOpenSearchModal] = useState(false)
@@ -439,55 +440,57 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
439
440
  />
440
441
  </IconWrapper>
441
442
  </View>
442
- <View style={styles.SLAwrapper}>
443
- <View style={{ flex: 0.5 }}>
444
- <OButton
445
- text={t('SLA_SETTING', 'SLA’s Settings')}
446
- textStyle={{ color: theme.colors.backArrow }}
447
- imgRightSrc={null}
448
- style={{
449
- backgroundColor: theme.colors.inputChat,
450
- borderRadius: 7.6,
451
- zIndex: 10,
452
- borderWidth: 0,
453
- minHeight: 40
454
- }}
455
- onClick={onClickSetting}
456
- />
457
- </View>
458
- <View style={{ width: 10, height: '100%' }} />
459
- <View style={{ flex: 0.5, justifyContent: 'center' }}>
460
- <SelectDropdown
461
- defaultButtonText={t('SLA', 'SLA\'s')}
462
- data={preorderTypeList}
463
- onSelect={(selectedItem, index) => {
464
- onFiltered && onFiltered({ ...search, timeStatus: selectedItem?.key })
465
- }}
466
- buttonTextAfterSelection={(selectedItem, index) => {
467
- return selectedItem.name
468
- }}
469
- rowTextForSelection={(item, index) => {
470
- return item.key
471
- }}
472
- buttonStyle={styles.selectOption}
473
- buttonTextStyle={styles.buttonTextStyle}
474
- renderDropdownIcon={isOpened => {
475
- return <FeatherIcon name={isOpened ? 'chevron-up' : 'chevron-down'} color={'#444'} size={18} />;
476
- }}
477
- dropdownStyle={styles.dropdownStyle}
478
- dropdownOverlayColor='transparent'
479
- rowStyle={styles.rowStyle}
480
- renderCustomizedRowChild={(item, index) => {
481
- return (
482
- <SlaOption>
483
- {index !== 0 && <OrderStatus timeState={item?.key} />}
484
- <View><OText size={14} color={'#748194'} >{item?.name}</OText></View>
485
- </SlaOption>
486
- );
487
- }}
488
- />
443
+ {configState?.configs?.order_deadlines_enabled?.value === '1' && (
444
+ <View style={styles.SLAwrapper}>
445
+ <View style={{ flex: 0.5 }}>
446
+ <OButton
447
+ text={t('SLA_SETTING', 'SLA’s Settings')}
448
+ textStyle={{ color: theme.colors.backArrow }}
449
+ imgRightSrc={null}
450
+ style={{
451
+ backgroundColor: theme.colors.inputChat,
452
+ borderRadius: 7.6,
453
+ zIndex: 10,
454
+ borderWidth: 0,
455
+ minHeight: 40
456
+ }}
457
+ onClick={onClickSetting}
458
+ />
459
+ </View>
460
+ <View style={{ width: 10, height: '100%' }} />
461
+ <View style={{ flex: 0.5, justifyContent: 'center' }}>
462
+ <SelectDropdown
463
+ defaultButtonText={t('SLA', 'SLA\'s')}
464
+ data={preorderTypeList}
465
+ onSelect={(selectedItem, index) => {
466
+ onFiltered && onFiltered({ ...search, timeStatus: selectedItem?.key })
467
+ }}
468
+ buttonTextAfterSelection={(selectedItem, index) => {
469
+ return selectedItem.name
470
+ }}
471
+ rowTextForSelection={(item, index) => {
472
+ return item.key
473
+ }}
474
+ buttonStyle={styles.selectOption}
475
+ buttonTextStyle={styles.buttonTextStyle}
476
+ renderDropdownIcon={isOpened => {
477
+ return <FeatherIcon name={isOpened ? 'chevron-up' : 'chevron-down'} color={'#444'} size={18} />;
478
+ }}
479
+ dropdownStyle={styles.dropdownStyle}
480
+ dropdownOverlayColor='transparent'
481
+ rowStyle={styles.rowStyle}
482
+ renderCustomizedRowChild={(item, index) => {
483
+ return (
484
+ <SlaOption>
485
+ {index !== 0 && <OrderStatus timeState={item?.key} />}
486
+ <View><OText size={14} color={'#748194'} >{item?.name}</OText></View>
487
+ </SlaOption>
488
+ );
489
+ }}
490
+ />
491
+ </View>
489
492
  </View>
490
- </View>
493
+ )}
491
494
  <FiltersTab>
492
495
  <ScrollView
493
496
  ref={scrollRefTab}
@@ -926,6 +929,7 @@ export const Timer = () => {
926
929
 
927
930
  export const OrdersOption = (props: OrdersOptionParams) => {
928
931
  const [, t] = useLanguage();
932
+ const [configState] = useConfig()
929
933
  const theme = useTheme()
930
934
  const ordersProps = {
931
935
  ...props,
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
2
2
  import { StyleSheet, TouchableOpacity, View, Platform, PlatformIOSStatic } from 'react-native';
3
3
  import { useTheme } from 'styled-components/native';
4
4
  import moment from 'moment'
5
- import { useLanguage, useUtils } from 'ordering-components/native';
5
+ import { useLanguage, useUtils, useConfig } from 'ordering-components/native';
6
6
  import { OButton, OIcon, OText } from '../shared';
7
7
  import {
8
8
  Card, Logo, Information, MyOrderOptions, NotificationIcon, AcceptOrRejectOrder, Timestatus
@@ -27,8 +27,14 @@ export const PreviousOrders = (props: any) => {
27
27
  } = props;
28
28
  const [, t] = useLanguage();
29
29
  const [{ parseDate, optimizeImage }] = useUtils();
30
+ const [configState] = useConfig()
30
31
  const theme = useTheme();
31
- const [currentTime, setCurrentTime] = useState()
32
+ const [, setCurrentTime] = useState()
33
+ const [allowColumns, setAllowColumns] = useState({
34
+ timer: true,
35
+ slaBar: true,
36
+ })
37
+
32
38
  const [orientationState] = useDeviceOrientation();
33
39
 
34
40
  const IS_PORTRAIT = orientationState.orientation === PORTRAIT
@@ -93,23 +99,41 @@ export const PreviousOrders = (props: any) => {
93
99
  },
94
100
  });
95
101
 
96
- const getDelayTime = (order: any) => {
102
+
103
+ const getDelayMinutes = (order: any) => {
97
104
  // targetMin = delivery_datetime + eta_time - now()
105
+ const offset = 300
106
+ const cdtToutc = parseDate(moment(order?.delivery_datetime).add(offset, 'minutes'))
98
107
  const _delivery = order?.delivery_datetime_utc
108
+ ? parseDate(order?.delivery_datetime_utc)
109
+ : parseDate(cdtToutc)
99
110
  const _eta = order?.eta_time
100
- const tagetedMin = moment(_delivery).add(_eta, 'minutes').diff(moment().utc(), 'minutes')
111
+ return moment(_delivery.replace('AM', '')).add(_eta, 'minutes').diff(moment().utc(), 'minutes')
112
+ }
113
+
114
+ const displayDelayedTime = (order: any) => {
115
+ let tagetedMin = getDelayMinutes(order)
116
+ // get day, hour and minutes
117
+ const sign = tagetedMin >= 0 ? '' : '- '
118
+ tagetedMin = Math.abs(tagetedMin)
101
119
  let day = Math.floor(tagetedMin / 1440)
102
120
  const restMinOfTargetedMin = tagetedMin - 1440 * day
103
- let restHours: any = Math.floor(restMinOfTargetedMin / 60)
104
- let restMins: any = restMinOfTargetedMin - 60 * restHours
121
+ let restHours = Math.floor(restMinOfTargetedMin / 60)
122
+ let restMins = restMinOfTargetedMin - 60 * restHours
123
+ // make standard time format
124
+ day = day === 0 ? '' : day + 'day '
125
+ restHours = restHours < 10 ? '0' + restHours : restHours
126
+ restMins = restMins < 10 ? '0' + restMins : restMins
105
127
 
106
- if (order?.time_status === 'in_time' || order?.time_status === 'at_risk') day = Math.abs(day)
107
- if (restHours < 10) restHours = ('0' + restHours)
108
- if (restMins < 10) restMins = ('0' + restMins)
109
- const finalTaget = day + 'day ' + restHours + ':' + restMins
128
+ const finalTaget = sign + day + restHours + ':' + restMins
110
129
  return finalTaget
111
130
  }
112
131
 
132
+ const getStatusClassName = (minutes: any) => {
133
+ if (isNaN(Number(minutes))) return 0
134
+ return minutes > 0 ? 'in_time' : minutes === 0 ? 'at_risk' : 'delayed'
135
+ }
136
+
113
137
  useEffect(() => {
114
138
  const interval = setInterval(() => {
115
139
  const date: any = Date.now()
@@ -119,6 +143,15 @@ export const PreviousOrders = (props: any) => {
119
143
  return () => clearInterval(interval)
120
144
  }, [])
121
145
 
146
+ useEffect(() => {
147
+ const slaSettings = configState?.configs?.order_deadlines_enabled?.value === '1'
148
+ setAllowColumns({
149
+ ...allowColumns,
150
+ timer: slaSettings,
151
+ slaBar: slaSettings
152
+ })
153
+ }, [configState.loading])
154
+
122
155
  let hash: any = {};
123
156
 
124
157
  return (
@@ -144,7 +177,9 @@ export const PreviousOrders = (props: any) => {
144
177
  activeOpacity={1}
145
178
  >
146
179
  <Card key={order.id}>
147
- <Timestatus style={{ backgroundColor: order?.time_status === 'in_time' ? '#00D27A' : order?.time_status === 'at_risk' ? '#FFC700' : order?.time_status === 'delayed' ? '#E63757' : '' }} />
180
+ {allowColumns?.slaBar && (
181
+ <Timestatus style={{ backgroundColor: getStatusClassName(getDelayMinutes(order)) === 'in_time' ? '#00D27A' : getStatusClassName(getDelayMinutes(order)) === 'at_risk' ? '#FFC700' : getStatusClassName(getDelayMinutes(order)) === 'delayed' ? '#E63757' : '' }} />
182
+ )}
148
183
  {
149
184
  order.business?.logo && (
150
185
  <Logo style={styles.logo}>
@@ -189,10 +224,10 @@ export const PreviousOrders = (props: any) => {
189
224
  ? parseDate(order?.delivery_datetime_utc, { outputFormat: 'MM/DD/YY · HH:mm a' })
190
225
  : parseDate(order?.delivery_datetime, { utc: false })}
191
226
  </OText>
192
- {(currentTabSelected === 'pending' || currentTabSelected === 'inProgress') && (
227
+ {((currentTabSelected === 'pending' || currentTabSelected === 'inProgress') && allowColumns?.timer) && (
193
228
  <>
194
229
  <OText> · </OText>
195
- <OText style={styles.date} color={order?.time_status === 'in_time' ? '#00D27A' : order?.time_status === 'at_risk' ? '#FFC700' : order?.time_status === 'delayed' ? '#E63757' : ''} >{getDelayTime(order)}</OText>
230
+ <OText style={styles.date} color={getStatusClassName(getDelayMinutes(order)) === 'in_time' ? '#00D27A' : getStatusClassName(getDelayMinutes(order)) === 'at_risk' ? '#FFC700' : getStatusClassName(getDelayMinutes(order)) === 'delayed' ? '#E63757' : ''} >{displayDelayedTime(order)}</OText>
196
231
  </>
197
232
  )}
198
233
  </View>
@@ -202,7 +202,7 @@ const OrderSummaryUI = (props: any) => {
202
202
  <OSRow>
203
203
  <OText size={12} numberOfLines={1}>
204
204
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
205
- ({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
205
+ ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%)
206
206
  </OText>
207
207
  <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
208
208
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />