ordering-ui-react-native 0.22.57 → 0.22.58-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.
Files changed (142) hide show
  1. package/package.json +5 -7
  2. package/src/DeliveryApp.tsx +1 -1
  3. package/src/components/BusinessesListing/index.tsx +1 -1
  4. package/src/components/Checkout/index.tsx +40 -39
  5. package/src/components/VerifyPhone/styles.tsx +1 -2
  6. package/src/context/OfflineActions/index.tsx +236 -0
  7. package/src/providers/AlertProvider.tsx +3 -1
  8. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +5 -3
  9. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  10. package/themes/business/src/components/BusinessController/index.tsx +8 -3
  11. package/themes/business/src/components/BusinessProductList/index.tsx +3 -2
  12. package/themes/business/src/components/Chat/index.tsx +15 -3
  13. package/themes/business/src/components/DriverMap/index.tsx +44 -33
  14. package/themes/business/src/components/FloatingButton/index.tsx +3 -2
  15. package/themes/business/src/components/LanguageSelector/index.tsx +1 -1
  16. package/themes/business/src/components/LoginForm/index.tsx +123 -98
  17. package/themes/business/src/components/LogoutButton/index.tsx +13 -4
  18. package/themes/business/src/components/MapView/RenderMarker.tsx +146 -0
  19. package/themes/business/src/components/MapView/index.tsx +68 -142
  20. package/themes/business/src/components/NewOrderNotification/index.tsx +25 -14
  21. package/themes/business/src/components/OrderDetails/Business.tsx +56 -20
  22. package/themes/business/src/components/OrderDetails/Delivery.tsx +123 -54
  23. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +146 -36
  24. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +51 -28
  25. package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
  26. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +17 -16
  27. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
  28. package/themes/business/src/components/OrderSummary/index.tsx +271 -176
  29. package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
  30. package/themes/business/src/components/OrdersOption/index.tsx +345 -231
  31. package/themes/business/src/components/OrdersOption/styles.tsx +14 -0
  32. package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
  33. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +30 -18
  34. package/themes/business/src/components/PreviousOrders/index.tsx +74 -66
  35. package/themes/business/src/components/PreviousOrders/styles.tsx +2 -1
  36. package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
  37. package/themes/business/src/components/PrinterEdition/index.tsx +143 -75
  38. package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
  39. package/themes/business/src/components/PrinterSettings/index.tsx +1 -1
  40. package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
  41. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  42. package/themes/business/src/components/StoresList/index.tsx +2 -2
  43. package/themes/business/src/components/UserProfileForm/index.tsx +48 -10
  44. package/themes/business/src/components/UserProfileForm/styles.tsx +7 -0
  45. package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
  46. package/themes/business/src/config/currency.tsx +1010 -0
  47. package/themes/business/src/hooks/useLocation.tsx +16 -12
  48. package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
  49. package/themes/business/src/types/index.tsx +33 -7
  50. package/themes/business/src/utils/index.tsx +28 -3
  51. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  52. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  53. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  54. package/themes/kiosk/src/components/Checkout/index.tsx +9 -5
  55. package/themes/kiosk/src/components/CustomerName/index.tsx +1 -1
  56. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  57. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  58. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  59. package/themes/kiosk/src/components/PaymentOptions/index.tsx +121 -57
  60. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  61. package/themes/original/index.tsx +223 -219
  62. package/themes/original/src/components/AddressForm/index.tsx +14 -8
  63. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  64. package/themes/original/src/components/BusinessBasicInformation/index.tsx +1 -1
  65. package/themes/original/src/components/BusinessController/index.tsx +4 -2
  66. package/themes/original/src/components/BusinessItemAccordion/index.tsx +10 -4
  67. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +103 -92
  68. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +7 -3
  69. package/themes/original/src/components/BusinessListingSearch/index.tsx +8 -13
  70. package/themes/original/src/components/BusinessPreorder/index.tsx +34 -15
  71. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +73 -70
  72. package/themes/original/src/components/BusinessProductsList/index.tsx +6 -7
  73. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  74. package/themes/original/src/components/BusinessProductsListing/index.tsx +10 -6
  75. package/themes/original/src/components/BusinessTypeFilter/index.tsx +9 -8
  76. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
  77. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  78. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  79. package/themes/original/src/components/Cart/index.tsx +50 -14
  80. package/themes/original/src/components/CartContent/index.tsx +2 -3
  81. package/themes/original/src/components/Checkout/index.tsx +133 -90
  82. package/themes/original/src/components/Favorite/index.tsx +1 -5
  83. package/themes/original/src/components/ForgotPasswordForm/index.tsx +1 -2
  84. package/themes/original/src/components/GoogleMap/index.tsx +6 -5
  85. package/themes/original/src/components/Help/functions.tsx +76 -0
  86. package/themes/original/src/components/Help/index.tsx +74 -29
  87. package/themes/original/src/components/Help/styles.tsx +4 -1
  88. package/themes/original/src/components/HelpOptions/index.tsx +44 -0
  89. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
  90. package/themes/original/src/components/Home/index.tsx +35 -16
  91. package/themes/original/src/components/LoginForm/index.tsx +12 -5
  92. package/themes/original/src/components/MessageListing/index.tsx +1 -1
  93. package/themes/original/src/components/Messages/index.tsx +20 -13
  94. package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
  95. package/themes/original/src/components/MomentOption/index.tsx +72 -51
  96. package/themes/original/src/components/MomentSelector/index.tsx +5 -2
  97. package/themes/original/src/components/MultiCheckout/index.tsx +78 -36
  98. package/themes/original/src/components/MyOrders/index.tsx +2 -2
  99. package/themes/original/src/components/NavBar/index.tsx +6 -2
  100. package/themes/original/src/components/NotFoundSource/index.tsx +40 -39
  101. package/themes/original/src/components/NotFoundSource/styles.tsx +18 -9
  102. package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
  103. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +11 -4
  104. package/themes/original/src/components/OrderDetails/index.tsx +44 -19
  105. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  106. package/themes/original/src/components/OrderProgress/index.tsx +4 -3
  107. package/themes/original/src/components/OrderSummary/index.tsx +32 -11
  108. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -3
  109. package/themes/original/src/components/OrdersOption/index.tsx +3 -6
  110. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  111. package/themes/original/src/components/PaymentOptions/index.tsx +471 -459
  112. package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
  113. package/themes/original/src/components/ProductForm/ActionButton.tsx +6 -10
  114. package/themes/original/src/components/ProductItemAccordion/index.tsx +28 -37
  115. package/themes/original/src/components/ProductOptionSubOption/index.tsx +15 -14
  116. package/themes/original/src/components/ServiceForm/index.tsx +1 -1
  117. package/themes/original/src/components/SignupForm/index.tsx +41 -24
  118. package/themes/original/src/components/SingleOrderCard/index.tsx +7 -4
  119. package/themes/original/src/components/SingleProductCard/index.tsx +3 -4
  120. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  121. package/themes/original/src/components/StripeCardsList/index.tsx +9 -4
  122. package/themes/original/src/components/StripeElementsForm/index.tsx +2 -2
  123. package/themes/original/src/components/StripeElementsForm/naked.tsx +1 -1
  124. package/themes/original/src/components/TaxInformation/index.tsx +3 -2
  125. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +7 -2
  126. package/themes/original/src/components/UserDetails/index.tsx +17 -16
  127. package/themes/original/src/components/UserFormDetails/index.tsx +109 -67
  128. package/themes/original/src/components/UserProfile/index.tsx +9 -1
  129. package/themes/original/src/components/UserVerification/index.tsx +18 -5
  130. package/themes/original/src/components/shared/OAlert.tsx +2 -1
  131. package/themes/original/src/components/shared/OButton.tsx +2 -2
  132. package/themes/original/src/components/shared/OInput.tsx +4 -8
  133. package/themes/original/src/components/shared/OModal.tsx +7 -2
  134. package/themes/original/src/types/index.tsx +699 -691
  135. package/themes/original/src/utils/index.tsx +29 -0
  136. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  137. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +0 -62
  138. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +0 -12
  139. package/themes/original/src/components/HelpGuide/index.tsx +0 -68
  140. package/themes/original/src/components/HelpGuide/styles.tsx +0 -12
  141. package/themes/original/src/components/HelpOrder/index.tsx +0 -71
  142. package/themes/original/src/components/HelpOrder/styles.tsx +0 -13
@@ -1,17 +1,19 @@
1
1
  import React, { useEffect, useState, useRef } from 'react';
2
2
  import { View, Pressable, StyleSheet, ScrollView, RefreshControl, Platform, TouchableOpacity } from 'react-native';
3
- import { useLanguage, useUtils, useToast, OrderListGroups, useConfig } from 'ordering-components/native';
3
+ import { useLanguage, useUtils, 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';
7
7
  import FontistoIcon from 'react-native-vector-icons/Fontisto'
8
8
  import AntDesignIcon from 'react-native-vector-icons/AntDesign'
9
+ import RNRestart from 'react-native-restart'
9
10
 
10
11
  import { useTheme } from 'styled-components/native';
11
12
  import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
12
13
  import { NotificationSetting } from '../../../../../src/components/NotificationSetting'
13
14
  import { NewOrderNotification } from '../NewOrderNotification';
14
15
  import { WebsocketStatus } from '../WebsocketStatus'
16
+ import { _retrieveStoreData, _setStoreData } from '../../providers/StoreUtil'
15
17
 
16
18
  import { OText, OButton, OModal, OInput, OIcon } from '../shared';
17
19
  import { NotFoundSource } from '../NotFoundSource';
@@ -35,7 +37,8 @@ import {
35
37
  ItemContent,
36
38
  TimerInputWrapper,
37
39
  OverLine,
38
- InputContainer
40
+ InputContainer,
41
+ FilterAlert
39
42
  } from './styles';
40
43
  import { PreviousOrders } from '../PreviousOrders';
41
44
  import { OrdersOptionParams } from '../../types';
@@ -53,6 +56,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
53
56
  navigation,
54
57
  setCurrentFilters,
55
58
  tabs,
59
+ combineTabs,
60
+ setCombineTabsState,
61
+ isNetConnected,
56
62
  currentTabSelected,
57
63
  setCurrentTabSelected,
58
64
  ordersGroup,
@@ -69,9 +75,9 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
69
75
  logisticOrders,
70
76
  loadLogisticOrders,
71
77
  isLogisticActivated,
72
- isAlsea,
73
78
  handleChangeOrderStatus,
74
- handleSendCustomerReview
79
+ handleSendCustomerReview,
80
+ ordersFiltered
75
81
  } = props;
76
82
 
77
83
  const defaultSearchList = {
@@ -95,12 +101,15 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
95
101
  const [, t] = useLanguage();
96
102
  const [{ parseDate }] = useUtils()
97
103
  const [configState] = useConfig()
104
+
98
105
  const [orientationState] = useDeviceOrientation();
99
106
  const [openSearchModal, setOpenSearchModal] = useState(false)
100
107
  const [openSLASettingModal, setOpenSLASettingModal] = useState(false)
101
108
  const [slaSettingTime, setSlaSettingTime] = useState(6000)
102
109
  const [currentDeliveryType, setCurrentDeliveryType] = useState('Delivery')
103
110
  const [search, setSearch] = useState(defaultSearchList)
111
+ const hasSearchFilters = JSON.stringify(defaultSearchList) !== JSON.stringify(search)
112
+
104
113
  const deliveryStatus = [
105
114
  {
106
115
  key: t('OK', 'Ok'),
@@ -124,12 +133,14 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
124
133
  backColor: '#E63757'
125
134
  }
126
135
  ]
127
- const combineTabs = configState?.configs?.combine_pending_and_progress_orders?.value === '1'
128
136
  const [selectedTabStatus, setSelectedTabStatus] = useState<any>(deliveryStatus)
129
137
  const [openedSelect, setOpenedSelect] = useState('')
138
+ const [lastDateConnection, setLastDateConnection] = useState(null)
139
+ const [internetLoading, setInternetLoading] = useState(!isNetConnected && isNetConnected !== null)
130
140
 
131
141
  const HEIGHT_SCREEN = orientationState?.dimensions?.height
132
142
  const IS_PORTRAIT = orientationState.orientation === PORTRAIT
143
+ const showTagsList = !props.isAlsea && !props.isDriverApp && currentTabSelected !== 'logisticOrders'
133
144
 
134
145
  const preorderTypeList = [
135
146
  { key: null, name: t('SLA', 'SLA\'s') },
@@ -251,7 +262,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
251
262
  paddingLeft: 0,
252
263
  paddingRight: 0,
253
264
  marginBottom: 30,
254
- marginTop: 30
265
+ marginTop: Platform.OS === 'ios' ? 60 : 30
255
266
  },
256
267
  rowStyle: {
257
268
  display: 'flex',
@@ -281,13 +292,27 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
281
292
 
282
293
  const tagsList = ordersGroup[currentTabSelected]?.defaultFilter ?? []
283
294
  const currentOrdersGroup = ordersGroup[currentTabSelected]
295
+ const ordersValidation = hasSearchFilters ? ordersFiltered : currentOrdersGroup
296
+
297
+ const paginationValidation =
298
+ !ordersValidation?.error?.length &&
299
+ !ordersValidation?.loading &&
300
+ ordersValidation?.pagination?.totalPages &&
301
+ ordersValidation?.pagination?.currentPage < ordersValidation?.pagination?.totalPages &&
302
+ ordersValidation?.orders?.length > 0
303
+
304
+ const loadingValidation = (
305
+ ordersValidation?.loading ||
306
+ (ordersValidation?.pagination?.total === null && isNetConnected) ||
307
+ logisticOrders?.loading
308
+ ) && !ordersValidation?.error?.length
284
309
 
285
310
  const isEqual = (array1: any, array2: any) => {
286
311
  return array1?.every((item: any) => array2.includes(item)) && array2?.every((item: any) => array1.includes(item))
287
312
  }
288
313
 
289
314
  const handleLoadMore = () => {
290
- loadMoreOrders && loadMoreOrders();
315
+ loadMoreOrders && loadMoreOrders({ allStatusses: hasSearchFilters });
291
316
  };
292
317
 
293
318
  const getOrderStatus = (key: number) => {
@@ -295,13 +320,6 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
295
320
  };
296
321
 
297
322
  const applyFilters = () => {
298
- setOrdersGroup({
299
- ...ordersGroup,
300
- [currentTabSelected]: {
301
- ...ordersGroup[currentTabSelected],
302
- orders: []
303
- }
304
- })
305
323
  const dateRange = calculateDate(search.date.type, search.date.from, search.date.to)
306
324
  onFiltered && onFiltered({ ...search, date: { ...dateRange } })
307
325
  setOpenSearchModal(false)
@@ -371,6 +389,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
371
389
  }
372
390
 
373
391
  const handleClose = () => {
392
+ setSearch(defaultSearchList)
374
393
  setOpenSearchModal(false)
375
394
  setOpenSLASettingModal(false)
376
395
  }
@@ -380,148 +399,194 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
380
399
  }
381
400
 
382
401
  useEffect(() => {
383
- scrollRefTab.current?.scrollTo({ animated: true });
384
- scrollListRef.current?.scrollTo({ animated: true });
385
- scrollRef.current?.scrollTo({ y: 0, animated: true });
402
+ scrollRefTab.current?.scrollTo();
403
+ scrollListRef.current?.scrollTo();
404
+ scrollRef.current?.scrollTo();
386
405
  setTags({ values: [] })
387
406
  }, [currentTabSelected])
388
407
 
389
- useEffect(() => {
390
- const unsubcribe = navigation.addListener('focus', () => {
391
- currentTabSelected === 'logisticOrders' ? loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true })
392
- })
393
- return unsubcribe
394
- }, [navigation, loadOrders, loadLogisticOrders])
408
+ useEffect(() => {
409
+ const unsubcribe = navigation.addListener('focus', () => {
410
+ currentTabSelected === 'logisticOrders' && loadLogisticOrders && loadLogisticOrders()
411
+ })
412
+ return unsubcribe
413
+ }, [navigation, loadLogisticOrders])
414
+
415
+ useEffect(() => {
416
+ const orderStatuses = ['active', 'pending', 'inProgress', 'completed', 'cancelled']
417
+
418
+ const manageStoragedOrders = async () => {
419
+ setInternetLoading(true)
420
+ let lastConnection = await _retrieveStoreData('last_date_connection');
421
+ let _combineTabs = await _retrieveStoreData('combine_pending_and_progress_orders')
422
+ let ordersStoraged: any = {}
423
+ for (const status of orderStatuses) {
424
+ ordersStoraged[status] = await _retrieveStoreData(`${status}_orders`) ?? []
425
+ }
426
+
427
+ if (_combineTabs || !_combineTabs && combineTabs) {
428
+ _combineTabs && setCombineTabsState(_combineTabs)
429
+ _setStoreData('combine_pending_and_progress_orders', _combineTabs || combineTabs);
430
+ }
431
+
432
+ if (!lastConnection) {
433
+ const formattedDate = parseDate(new Date())
434
+ lastConnection = formattedDate
435
+ _setStoreData('last_date_connection', formattedDate);
436
+ }
437
+
438
+ lastConnection && setLastDateConnection(lastConnection)
439
+
440
+ if (Object.values(ordersStoraged).every((key: any) => Array.isArray(key) && !key?.length)) {
441
+ for (const status of orderStatuses) {
442
+ ordersStoraged[status] = ordersGroup[status]?.orders
443
+ _setStoreData(`${status}_orders`, ordersGroup[status]?.orders);
444
+ }
445
+ }
446
+
447
+ if (Object.values(ordersStoraged).some((key: any) => Array.isArray(key) && key?.length)) {
448
+ let newOrderGroup = {
449
+ ...ordersGroup
450
+ }
451
+ for (const status of orderStatuses) {
452
+ newOrderGroup[status] = {
453
+ ...ordersGroup[status],
454
+ error: null,
455
+ orders: ordersStoraged[status]
456
+ }
457
+ }
458
+ setOrdersGroup(newOrderGroup)
459
+ }
460
+ setInternetLoading(false)
461
+ };
462
+
463
+ if (isNetConnected) {
464
+ _setStoreData('last_date_connection', null);
465
+ _setStoreData('combine_pending_and_progress_orders', null);
466
+ orderStatuses.forEach((key: any) => _setStoreData(`${key}_orders`, null))
467
+ } else if (isNetConnected === false) {
468
+ manageStoragedOrders()
469
+ }
470
+ }, [isNetConnected]);
395
471
 
396
472
  return (
397
473
  <>
474
+ {hasSearchFilters && (
475
+ <FilterAlert>
476
+ <AntDesignIcon
477
+ name='warning'
478
+ color='#FFC700'
479
+ size={12}
480
+ onPress={() => setOpenSearchModal(true)}
481
+ />
482
+ <OText size={10} mLeft={5} mRight={5}>
483
+ {t('WARNING_FILTER_APPLIED', 'Filters applied. You may miss new orders.')}
484
+ </OText>
485
+ <Pressable onPress={() => handleClearFilters()}>
486
+ <OText textDecorationLine='underline' size={10} color='rgb(44, 123, 229)'>{t('CLEAR_FILTERS', 'Clear filters')}</OText>
487
+ </Pressable>
488
+ </FilterAlert>
489
+ )}
398
490
  <View style={styles.header}>
399
491
  <OText style={styles.title}>{t('MY_ORDERS', 'My orders')}</OText>
400
492
  <IconWrapper>
401
493
  <View style={{ marginRight: 10 }}>
402
494
  <WebsocketStatus />
403
495
  </View>
404
- <FeatherIcon
405
- name='refresh-cw'
406
- color={theme.colors.backgroundDark}
407
- size={24}
408
- onPress={() => { currentTabSelected === 'logisticOrders' ? loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true }) }}
409
- style={{ marginRight: 20 }}
410
- />
411
- <FontistoIcon
412
- name='search'
413
- color={theme.colors.backgroundDark}
414
- size={24}
415
- onPress={() => setOpenSearchModal(true)}
416
- />
417
- </IconWrapper>
418
- </View>
419
- {configState?.configs?.order_deadlines_enabled?.value === '1' && (
420
- <View style={styles.SLAwrapper}>
421
- {/* <View style={{ flex: 0.5 }}>
422
- <OButton
423
- text={t('SLA_SETTING', 'SLA’s Settings')}
424
- textStyle={{ color: theme.colors.backArrow }}
425
- imgRightSrc={null}
496
+ {isNetConnected && (
497
+ <FeatherIcon
498
+ name='refresh-cw'
499
+ color={theme.colors.backgroundDark}
500
+ size={24}
501
+ onPress={() => currentTabSelected === 'logisticOrders' ? loadLogisticOrders && loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true, }, { allStatusses: hasSearchFilters })}
426
502
  style={{
427
- backgroundColor: theme.colors.inputChat,
428
- borderRadius: 7.6,
429
- zIndex: 10,
430
- borderWidth: 0,
431
- minHeight: 40
503
+ marginRight: 20
432
504
  }}
433
- onClick={onClickSetting}
434
505
  />
435
- </View> */}
436
- {/* <View style={{ width: 10, height: '100%' }} /> */}
437
- {/* <View style={{ flex: 0.5, justifyContent: 'center' }}>
438
- <SelectDropdown
439
- defaultButtonText={t('SLA', 'SLA\'s')}
440
- data={preorderTypeList}
441
- onSelect={(selectedItem, index) => {
442
- onFiltered && onFiltered({ ...search, timeStatus: selectedItem?.key })
443
- }}
444
- buttonTextAfterSelection={(selectedItem, index) => {
445
- return selectedItem.name
446
- }}
447
- rowTextForSelection={(item, index) => {
448
- return item.key
449
- }}
450
- buttonStyle={styles.selectOption}
451
- buttonTextStyle={styles.buttonTextStyle}
452
- renderDropdownIcon={isOpened => {
453
- return <FeatherIcon name={isOpened ? 'chevron-up' : 'chevron-down'} color={'#444'} size={18} />;
454
- }}
455
- dropdownStyle={styles.dropdownStyle}
456
- dropdownOverlayColor='transparent'
457
- rowStyle={styles.rowStyle}
458
- renderCustomizedRowChild={(item, index) => {
459
- return (
460
- <SlaOption>
461
- {index !== 0 && <OrderStatus timeState={item?.key} />}
462
- <View><OText size={14} color={'#748194'} >{item?.name}</OText></View>
463
- </SlaOption>
464
- );
465
- }}
466
- />
467
- </View> */}
468
- </View>
469
- )}
470
- <FiltersTab>
471
- <ScrollView
472
- ref={scrollRefTab}
473
- showsVerticalScrollIndicator={false}
474
- showsHorizontalScrollIndicator={false}
475
- horizontal
476
- nestedScrollEnabled={true}
477
- >
478
- <TabsContainer>
479
- {(isLogisticActivated && !isBusinessApp && !combineTabs) && (
480
- <Pressable
481
- style={styles.pressable}
482
- onPress={() => setCurrentTabSelected('logisticOrders')}>
483
- <OIcon
484
- src={theme.images?.general?.chronometer}
485
- borderBottomWidth={currentTabSelected === 'logisticOrders' ? 1 : 0}
486
- width={currentTabSelected === 'logisticOrders' ? 26 : 24}
487
- height={currentTabSelected === 'logisticOrders' ? 26 : 24}
488
- color={
489
- currentTabSelected === 'logisticOrders'
490
- ? theme.colors.textGray
491
- : theme.colors.unselectText
492
- }
493
- style={styles.icon}
494
- />
495
- </Pressable>
496
- )}
497
- {tabs.map((tab: any) => (
498
- <TabPressable
499
- key={tab.key}
500
- onPress={() => setCurrentTabSelected(tab?.title)}
501
- isSelected={tab.title === currentTabSelected ? 1 : 0}
502
- >
503
- <OText
506
+ )}
507
+ {currentTabSelected !== 'logisticOrders' && (
508
+ <View>
509
+ {hasSearchFilters && (
510
+ <AntDesignIcon
511
+ name='exclamationcircle'
512
+ color={theme.colors.primary}
513
+ size={16}
504
514
  style={{
505
- ...styles.tab,
506
- fontSize: tab.title === currentTabSelected ? 16 : 14,
507
- borderBottomWidth: Platform.OS === 'ios' && tab.title === currentTabSelected ? 1 : 0,
515
+ position: 'absolute',
516
+ zIndex: 1000,
517
+ right: -8,
518
+ top: -5
508
519
  }}
509
- color={
510
- tab.title === currentTabSelected
511
- ? theme.colors.textGray
512
- : theme.colors.unselectText
513
- }
514
- weight={tab.title === currentTabSelected ? '600' : 'normal'}
520
+ onPress={() => setOpenSearchModal(true)}
521
+ />
522
+ )}
523
+ <FontistoIcon
524
+ name='filter'
525
+ color={theme.colors.backgroundDark}
526
+ size={24}
527
+ onPress={() => setOpenSearchModal(true)}
528
+ />
529
+ </View>
530
+ )}
531
+ </IconWrapper>
532
+ </View>
533
+ {!hasSearchFilters && (
534
+ <FiltersTab>
535
+ <ScrollView
536
+ ref={scrollRefTab}
537
+ showsVerticalScrollIndicator={false}
538
+ showsHorizontalScrollIndicator={false}
539
+ horizontal
540
+ nestedScrollEnabled={true}
541
+ >
542
+ <TabsContainer>
543
+ {(isLogisticActivated && !isBusinessApp && !combineTabs) && (
544
+ <Pressable
545
+ style={styles.pressable}
546
+ onPress={() => setCurrentTabSelected('logisticOrders')}>
547
+ <OIcon
548
+ src={theme.images?.general?.chronometer}
549
+ borderBottomWidth={currentTabSelected === 'logisticOrders' ? 1 : 0}
550
+ width={currentTabSelected === 'logisticOrders' ? 26 : 24}
551
+ height={currentTabSelected === 'logisticOrders' ? 26 : 24}
552
+ color={
553
+ currentTabSelected === 'logisticOrders'
554
+ ? theme.colors.textGray
555
+ : theme.colors.unselectText
556
+ }
557
+ style={styles.icon}
558
+ />
559
+ </Pressable>
560
+ )}
561
+ {!hasSearchFilters && tabs.map((tab: any) => (
562
+ <TabPressable
563
+ key={tab.key}
564
+ onPress={() => setCurrentTabSelected(tab?.title)}
565
+ isSelected={tab.title === currentTabSelected ? 1 : 0}
515
566
  >
516
- {tab.text}
517
- </OText>
518
- </TabPressable>
519
- ))}
520
- </TabsContainer>
521
- </ScrollView>
522
- </FiltersTab>
567
+ <OText
568
+ style={{
569
+ ...styles.tab,
570
+ fontSize: tab.title === currentTabSelected ? 16 : 14,
571
+ borderBottomWidth: Platform.OS === 'ios' && tab.title === currentTabSelected ? 1 : 0,
572
+ }}
573
+ color={
574
+ tab.title === currentTabSelected
575
+ ? theme.colors.textGray
576
+ : theme.colors.unselectText
577
+ }
578
+ weight={tab.title === currentTabSelected ? '600' : 'normal'}
579
+ >
580
+ {tab.text}
581
+ </OText>
582
+ </TabPressable>
583
+ ))}
584
+ </TabsContainer>
585
+ </ScrollView>
586
+ </FiltersTab>
587
+ )}
523
588
  <View style={{ flex: 1, minHeight: HEIGHT_SCREEN - 450 }}>
524
- {currentTabSelected !== 'logisticOrders' && !isAlsea && (
589
+ {showTagsList && !hasSearchFilters && (
525
590
  <View
526
591
  style={{
527
592
  display: 'flex',
@@ -588,6 +653,22 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
588
653
  </ScrollView>
589
654
  </View>
590
655
  )}
656
+ {isNetConnected === false && lastDateConnection && (
657
+ <View
658
+ style={{
659
+ borderRadius: 8,
660
+ paddingVertical: 3,
661
+ backgroundColor: theme.colors.danger500,
662
+ marginBottom: 10
663
+ }}
664
+ >
665
+ <OText
666
+ style={{ color: 'white', textAlign: 'center' }}
667
+ >
668
+ {`${t('LAST_UPDATE', 'Last Update')}: ${lastDateConnection}`}
669
+ </OText>
670
+ </View>
671
+ )}
591
672
  <ScrollView
592
673
  ref={scrollListRef}
593
674
  showsVerticalScrollIndicator={false}
@@ -596,16 +677,17 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
596
677
  refreshControl={
597
678
  <RefreshControl
598
679
  refreshing={refreshing}
599
- onRefresh={() => { currentTabSelected === 'logisticOrders' ? loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true }) }}
680
+ onRefresh={() => { isNetConnected && (currentTabSelected === 'logisticOrders' ? loadLogisticOrders && loadLogisticOrders() : loadOrders && loadOrders({ newFetch: true }, { allStatusses: hasSearchFilters })) }}
600
681
  />
601
682
  }
602
683
  >
603
- {!currentOrdersGroup?.error?.length &&
604
- currentOrdersGroup?.orders?.length > 0 &&
684
+ {!ordersValidation?.error?.length &&
685
+ (ordersValidation?.orders?.length > 0 || ordersFiltered?.orders?.length > 0) &&
605
686
  currentTabSelected !== 'logisticOrders' &&
687
+ !ordersValidation?.loading &&
606
688
  (
607
689
  <PreviousOrders
608
- orders={ordersFormatted}
690
+ orders={hasSearchFilters ? ordersFiltered?.orders : ordersFormatted}
609
691
  navigation={props.navigation}
610
692
  onNavigationRedirect={onNavigationRedirect}
611
693
  getOrderStatus={getOrderStatus}
@@ -621,7 +703,8 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
621
703
  />
622
704
  )}
623
705
  {!logisticOrders?.error?.length &&
624
- logisticOrders?.orders?.length > 0 &&
706
+ logisticOrders && logisticOrders?.orders?.length > 0 &&
707
+ !logisticOrders?.loading &&
625
708
  currentTabSelected === 'logisticOrders' && (
626
709
  <PreviousOrders
627
710
  orders={logisticOrders?.orders?.filter((order: any) => !order?.expired).map((order: any) => ({ ...order, isLogistic: true }))}
@@ -633,46 +716,40 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
633
716
  />
634
717
  )
635
718
  }
636
- {((currentOrdersGroup?.loading ||
637
- currentOrdersGroup?.pagination?.total === null) ||
638
- (logisticOrders?.loading)) &&
639
- (
640
- <>
641
- <View>
642
- {[...Array(5)].map((_, i) => (
643
- <Placeholder key={i} Animation={Fade}>
644
- <View
719
+ {(
720
+ loadingValidation || internetLoading
721
+ ) && (
722
+ <View style={{ marginTop: 10 }}>
723
+ {[...Array(5)].map((_, i) => (
724
+ <Placeholder key={i} Animation={Fade}>
725
+ <View
726
+ style={{
727
+ width: '100%',
728
+ flexDirection: 'row',
729
+ marginBottom: 10,
730
+ }}>
731
+ <PlaceholderLine
732
+ width={IS_PORTRAIT ? 22 : 11}
733
+ height={74}
645
734
  style={{
646
- width: '100%',
647
- flexDirection: 'row',
648
- marginBottom: 10,
649
- }}>
650
- <PlaceholderLine
651
- width={IS_PORTRAIT ? 22 : 11}
652
- height={74}
653
- style={{
654
- marginRight: 20,
655
- marginBottom: 20,
656
- borderRadius: 7.6,
657
- }}
658
- />
659
- <Placeholder>
660
- <PlaceholderLine width={30} style={{ marginTop: 5 }} />
661
- <PlaceholderLine width={50} />
662
- <PlaceholderLine width={20} />
663
- </Placeholder>
664
- </View>
665
- </Placeholder>
666
- ))}
667
- </View>
668
- </>
735
+ marginRight: 20,
736
+ marginBottom: 20,
737
+ borderRadius: 7.6,
738
+ }}
739
+ />
740
+ <Placeholder>
741
+ <PlaceholderLine width={30} style={{ marginTop: 5 }} />
742
+ <PlaceholderLine width={50} />
743
+ <PlaceholderLine width={20} />
744
+ </Placeholder>
745
+ </View>
746
+ </Placeholder>
747
+ ))}
748
+ </View>
669
749
  )}
670
750
 
671
- {!currentOrdersGroup?.error?.length &&
672
- !currentOrdersGroup?.loading &&
673
- currentOrdersGroup?.pagination?.totalPages &&
674
- currentOrdersGroup?.pagination?.currentPage < currentOrdersGroup?.pagination?.totalPages &&
675
- currentOrdersGroup?.orders?.length > 0 &&
751
+ {isNetConnected &&
752
+ paginationValidation &&
676
753
  (
677
754
  <OButton
678
755
  onClick={handleLoadMore}
@@ -685,33 +762,35 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
685
762
  />
686
763
  )}
687
764
 
688
- {((!currentOrdersGroup?.loading &&
689
- (currentOrdersGroup?.error?.length ||
690
- currentOrdersGroup?.orders?.length === 0)) ||
691
- (currentTabSelected === 'logisticOrders' &&
692
- (logisticOrders?.error?.length > 0 || logisticOrders?.orders?.length === 0 || !logisticOrders?.orders?.some(order => !order?.expired)))
693
- ) &&
765
+ {!internetLoading &&
766
+ ((!ordersValidation?.loading &&
767
+ (ordersValidation?.error?.length ||
768
+ ordersValidation?.orders?.length === 0)) ||
769
+ (currentTabSelected === 'logisticOrders' &&
770
+ (logisticOrders && !logisticOrders?.loading && (logisticOrders?.error?.length > 0 || logisticOrders?.orders?.length === 0 || !logisticOrders?.orders?.some(order => !order?.expired))))
771
+ ) &&
694
772
  (
695
773
  <NotFoundSource
696
774
  content={
697
- ((currentTabSelected !== 'logisticOrders' && !currentOrdersGroup?.error?.length) ||
698
- (currentTabSelected === 'logisticOrders' && (!logisticOrders?.error?.length || (logisticOrders?.orders?.length > 0 && !logisticOrders?.orders?.some(order => !order?.expired)))))
699
- ? t('NO_RESULTS_FOUND', 'Sorry, no results found')
700
- : currentOrdersGroup?.error?.[0]?.message ||
701
- currentOrdersGroup?.error?.[0] ||
702
- (currentTabSelected === 'logisticOrders' && logisticOrders?.error) ||
703
- t('NETWORK_ERROR', 'Network Error')
775
+ !isNetConnected ? t('NETWORK_ERROR', 'Network Error') :
776
+ ((currentTabSelected !== 'logisticOrders' && !ordersValidation?.error?.length) ||
777
+ (currentTabSelected === 'logisticOrders' && (!logisticOrders?.error?.length || (logisticOrders?.orders?.length > 0 && !logisticOrders?.orders?.some(order => !order?.expired)))))
778
+ ? t('NO_RESULTS_FOUND', 'Sorry, no results found')
779
+ : ordersValidation?.error?.[0]?.message ||
780
+ ordersValidation?.error?.[0] ||
781
+ (currentTabSelected === 'logisticOrders' && logisticOrders?.error) ||
782
+ t('NETWORK_ERROR', 'Network Error')
704
783
  }
705
784
  image={theme.images.general.notFound}
706
785
  conditioned={false}
786
+ btnTitle={!isNetConnected && t('REFRESH', 'Refresh')}
787
+ onClickButton={!isNetConnected && (() => RNRestart.Restart())}
707
788
  />
708
789
  )}
709
790
  </ScrollView>
710
791
  </View>
711
792
 
712
- {isBusinessApp && (
713
- <NewOrderNotification isBusinessApp={isBusinessApp} />
714
- )}
793
+ <NewOrderNotification isBusinessApp={isBusinessApp} />
715
794
 
716
795
  {(openSearchModal || openSLASettingModal) && (
717
796
  <OModal open={openSearchModal || openSLASettingModal} entireModal customClose>
@@ -724,39 +803,41 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
724
803
  {openSearchModal && (
725
804
  <SearchModalContent>
726
805
  <ModalTitle>{t('SEARCH_ORDERS', 'Search orders')}</ModalTitle>
727
- <InputContainer style={{ marginBottom: 24 }}>
728
- <SelectDropdown
729
- defaultButtonText={search?.timeStatus
730
- ? preorderTypeList.find(type => type.key === search?.timeStatus)?.name
731
- : t('SLA', 'SLA\'s')}
732
- data={preorderTypeList}
733
- onSelect={(selectedItem, index) => {
734
- setSearch({ ...search, timeStatus: selectedItem?.key })
735
- }}
736
- buttonTextAfterSelection={(selectedItem, index) => {
737
- return selectedItem.name
738
- }}
739
- rowTextForSelection={(item, index) => {
740
- return item.key
741
- }}
742
- buttonStyle={styles.selectOption}
743
- buttonTextStyle={styles.buttonTextStyle}
744
- renderDropdownIcon={isOpened => {
745
- return <FeatherIcon name={isOpened ? 'chevron-up' : 'chevron-down'} color={'#444'} size={18} />;
746
- }}
747
- dropdownStyle={styles.dropdownStyle}
748
- dropdownOverlayColor='transparent'
749
- rowStyle={styles.rowStyle}
750
- renderCustomizedRowChild={(item, index) => {
751
- return (
752
- <SlaOption>
753
- {index !== 0 && <OrderStatus timeState={item?.key} />}
754
- <View><OText size={14} color={'#748194'} >{item?.name}</OText></View>
755
- </SlaOption>
756
- );
757
- }}
758
- />
759
- </InputContainer>
806
+ {configState?.configs?.order_deadlines_enabled?.value === '1' && (
807
+ <InputContainer style={{ marginBottom: 24 }}>
808
+ <SelectDropdown
809
+ defaultButtonText={search?.timeStatus
810
+ ? preorderTypeList.find(type => type.key === search?.timeStatus)?.name
811
+ : t('SLA', 'SLA\'s')}
812
+ data={preorderTypeList}
813
+ onSelect={(selectedItem, index) => {
814
+ setSearch({ ...search, timeStatus: selectedItem?.key })
815
+ }}
816
+ buttonTextAfterSelection={(selectedItem, index) => {
817
+ return selectedItem.name
818
+ }}
819
+ rowTextForSelection={(item, index) => {
820
+ return item.key
821
+ }}
822
+ buttonStyle={styles.selectOption}
823
+ buttonTextStyle={styles.buttonTextStyle}
824
+ renderDropdownIcon={isOpened => {
825
+ return <FeatherIcon name={isOpened ? 'chevron-up' : 'chevron-down'} color={'#444'} size={18} />;
826
+ }}
827
+ dropdownStyle={styles.dropdownStyle}
828
+ dropdownOverlayColor='transparent'
829
+ rowStyle={styles.rowStyle}
830
+ renderCustomizedRowChild={(item, index) => {
831
+ return (
832
+ <SlaOption>
833
+ {index !== 0 && <OrderStatus timeState={item?.key} />}
834
+ <View><OText size={14} color={'#748194'} >{item?.name}</OText></View>
835
+ </SlaOption>
836
+ );
837
+ }}
838
+ />
839
+ </InputContainer>
840
+ )}
760
841
  <InputContainer>
761
842
  <OInput
762
843
  value={search.id}
@@ -985,12 +1066,29 @@ export const OrdersOption = (props: OrdersOptionParams) => {
985
1066
  const [, t] = useLanguage();
986
1067
  const [configState] = useConfig()
987
1068
  const [checkNotificationStatus, setCheckNotificationStatus] = useState({ open: false, checked: false })
988
- const combineTabs = configState?.configs?.combine_pending_and_progress_orders?.value === '1'
1069
+ const [combineTabs, setCombineTabs] = useState(null)
1070
+
1071
+ useEffect(() => {
1072
+ const getCombineTabsStoraged = async () => {
1073
+ try {
1074
+ const storagedValue = await _retrieveStoreData('combine_pending_and_progress_orders');
1075
+ const _combineTabs = typeof configState?.configs?.combine_pending_and_progress_orders === 'object'
1076
+ ? configState?.configs?.combine_pending_and_progress_orders?.value === '1'
1077
+ : storagedValue
1078
+ setCombineTabs(_combineTabs)
1079
+ } catch {
1080
+ return null
1081
+ }
1082
+ }
1083
+ getCombineTabsStoraged()
1084
+ }, [])
1085
+
989
1086
  const ordersProps = {
990
1087
  ...props,
991
1088
  UIComponent: OrdersOptionUI,
992
1089
  useDefualtSessionManager: true,
993
1090
  asDashboard: true,
1091
+ combineTabs,
994
1092
  isIos: Platform.OS === 'ios',
995
1093
  orderStatus: [
996
1094
  { key: 0, text: t('PENDING', 'Pending') },
@@ -1070,13 +1168,25 @@ export const OrdersOption = (props: OrdersOptionParams) => {
1070
1168
  {
1071
1169
  key: 23,
1072
1170
  text: t('ORDER_DRIVER_ON_WAY', 'Driver on way')
1171
+ },
1172
+ {
1173
+ key: 24,
1174
+ text: t('ORDER_DRIVER_WAITING_FOR_ORDER', 'Driver waiting for order')
1175
+ },
1176
+ {
1177
+ key: 25,
1178
+ text: t('ORDER_ACCEPTED_BY_DRIVER_COMPANY', 'Accepted by driver company')
1179
+ },
1180
+ {
1181
+ key: 26,
1182
+ text: t('ORDER_DRIVER_ARRIVED_CUSTOMER', 'Driver arrived to customer')
1073
1183
  }
1074
1184
  ],
1075
1185
  tabs: combineTabs ? [
1076
1186
  {
1077
1187
  key: 0,
1078
1188
  text: t('ACTIVE', 'Active'),
1079
- tags: props?.orderGroupStatusCustom?.active ?? [0, 3, 4, 7, 8, 9, 13, 14, 18, 19, 20, 21, 22, 23],
1189
+ tags: props?.orderGroupStatusCustom?.active ?? [0, 3, 4, 7, 8, 9, 13, 14, 18, 19, 20, 21, 22, 23, 24, 25, 26],
1080
1190
  title: 'active',
1081
1191
  },
1082
1192
  {
@@ -1102,7 +1212,7 @@ export const OrdersOption = (props: OrdersOptionParams) => {
1102
1212
  {
1103
1213
  key: 1,
1104
1214
  text: t('IN_PROGRESS', 'In Progress'),
1105
- tags: props?.orderGroupStatusCustom?.inProgress ?? [3, 4, 7, 8, 9, 14, 18, 19, 20, 21, 22, 23],
1215
+ tags: props?.orderGroupStatusCustom?.inProgress ?? [3, 4, 7, 8, 9, 14, 18, 19, 20, 21, 22, 23, 24, 25, 26],
1106
1216
  title: 'inProgress',
1107
1217
  },
1108
1218
  {
@@ -1128,3 +1238,7 @@ export const OrdersOption = (props: OrdersOptionParams) => {
1128
1238
  )}
1129
1239
  </>);
1130
1240
  };
1241
+
1242
+ OrdersOption.defaultProps = {
1243
+ isNetConnected: true
1244
+ }