ordering-ui-react-native 0.16.48 → 0.16.49-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 (208) hide show
  1. package/package.json +6 -5
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/ActiveOrders/index.tsx +61 -63
  4. package/src/components/ActiveOrders/styles.tsx +8 -14
  5. package/src/components/BusinessBasicInformation/index.tsx +11 -19
  6. package/src/components/BusinessInformation/index.tsx +33 -4
  7. package/src/components/BusinessInformation/styles.tsx +2 -2
  8. package/src/components/BusinessProductsList/index.tsx +10 -10
  9. package/src/components/BusinessesListing/index.tsx +1 -1
  10. package/src/components/Checkout/index.tsx +2 -1
  11. package/src/components/LanguageSelector/index.tsx +21 -16
  12. package/src/components/Messages/index.tsx +2 -2
  13. package/src/components/NotificationSetting/index.tsx +85 -0
  14. package/src/components/OrdersOption/index.tsx +54 -56
  15. package/src/components/PaymentOptions/index.tsx +298 -345
  16. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  17. package/src/components/ReviewDriver/index.tsx +1 -1
  18. package/src/components/ReviewOrder/index.tsx +2 -2
  19. package/src/components/ReviewProducts/index.tsx +11 -0
  20. package/src/components/SingleProductReview/index.tsx +8 -5
  21. package/src/components/StripeElementsForm/index.tsx +25 -16
  22. package/src/components/VerifyPhone/styles.tsx +1 -2
  23. package/src/components/shared/OBottomPopup.tsx +6 -2
  24. package/src/components/shared/OToast.tsx +4 -4
  25. package/src/index.tsx +2 -0
  26. package/src/types/@fatnlazycat/react-native-recaptcha-v3/index.d.ts +1 -0
  27. package/src/utils/index.tsx +2 -1
  28. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +259 -238
  29. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
  30. package/themes/business/src/components/BusinessController/index.tsx +2 -2
  31. package/themes/business/src/components/Chat/index.tsx +40 -32
  32. package/themes/business/src/components/DriverMap/index.tsx +7 -5
  33. package/themes/business/src/components/DriverSchedule/index.tsx +36 -19
  34. package/themes/business/src/components/LoginForm/index.tsx +111 -74
  35. package/themes/business/src/components/MapView/index.tsx +12 -1
  36. package/themes/business/src/components/MessagesOption/index.tsx +11 -1
  37. package/themes/business/src/components/NewOrderNotification/index.tsx +26 -41
  38. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +40 -30
  39. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +3 -3
  40. package/themes/business/src/components/OrdersListManager/index.tsx +10 -3
  41. package/themes/business/src/components/OrdersOption/index.tsx +76 -77
  42. package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
  43. package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
  44. package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
  45. package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
  46. package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
  47. package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
  48. package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
  49. package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
  50. package/themes/business/src/components/PreviousMessages/index.tsx +17 -18
  51. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
  52. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
  53. package/themes/business/src/components/PreviousOrders/index.tsx +332 -244
  54. package/themes/business/src/components/PreviousOrders/styles.tsx +30 -2
  55. package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
  56. package/themes/business/src/components/ReviewCustomer/index.tsx +39 -15
  57. package/themes/business/src/components/ScheduleBlocked/index.tsx +2 -2
  58. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  59. package/themes/business/src/components/UserProfileForm/index.tsx +2 -0
  60. package/themes/business/src/components/shared/ODropDown.tsx +42 -8
  61. package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
  62. package/themes/business/src/components/shared/OLink.tsx +24 -12
  63. package/themes/business/src/components/shared/OText.tsx +3 -2
  64. package/themes/business/src/types/index.tsx +25 -11
  65. package/themes/business/src/utils/index.tsx +10 -0
  66. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  67. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  68. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  69. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -1
  70. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  71. package/themes/kiosk/src/components/LoginForm/index.tsx +121 -10
  72. package/themes/kiosk/src/components/LoginForm/styles.tsx +5 -0
  73. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  74. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  75. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  76. package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
  77. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  78. package/themes/kiosk/src/types/index.d.ts +2 -0
  79. package/themes/original/index.tsx +8 -0
  80. package/themes/original/src/components/AddressDetails/index.tsx +10 -8
  81. package/themes/original/src/components/AddressForm/index.tsx +157 -140
  82. package/themes/original/src/components/AddressList/index.tsx +1 -1
  83. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  84. package/themes/original/src/components/BusinessBasicInformation/index.tsx +218 -147
  85. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +2 -2
  86. package/themes/original/src/components/BusinessController/index.tsx +231 -114
  87. package/themes/original/src/components/BusinessController/styles.tsx +14 -9
  88. package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
  89. package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -6
  90. package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
  91. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
  92. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
  93. package/themes/original/src/components/BusinessListingSearch/index.tsx +109 -139
  94. package/themes/original/src/components/BusinessListingSearch/styles.tsx +10 -12
  95. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
  96. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
  97. package/themes/original/src/components/BusinessProductsList/index.tsx +59 -60
  98. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  99. package/themes/original/src/components/BusinessProductsListing/index.tsx +177 -80
  100. package/themes/original/src/components/BusinessProductsListing/styles.tsx +18 -11
  101. package/themes/original/src/components/BusinessTypeFilter/index.tsx +3 -2
  102. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +35 -23
  103. package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +3 -2
  104. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +275 -120
  105. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +47 -10
  106. package/themes/original/src/components/BusinessesListing/index.tsx +80 -25
  107. package/themes/original/src/components/Cart/index.tsx +82 -15
  108. package/themes/original/src/components/Cart/styles.tsx +4 -0
  109. package/themes/original/src/components/CartContent/index.tsx +22 -16
  110. package/themes/original/src/components/Checkout/index.tsx +114 -118
  111. package/themes/original/src/components/Checkout/styles.tsx +4 -3
  112. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  113. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  114. package/themes/original/src/components/DriverTips/index.tsx +4 -4
  115. package/themes/original/src/components/DriverTips/styles.tsx +2 -1
  116. package/themes/original/src/components/FavoriteList/index.tsx +69 -45
  117. package/themes/original/src/components/FloatingButton/index.tsx +13 -11
  118. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  119. package/themes/original/src/components/GPSButton/index.tsx +20 -19
  120. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  121. package/themes/original/src/components/GoogleMap/index.tsx +20 -12
  122. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +25 -10
  123. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +4 -0
  124. package/themes/original/src/components/HelpGuide/index.tsx +9 -8
  125. package/themes/original/src/components/HelpOrder/index.tsx +9 -8
  126. package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
  127. package/themes/original/src/components/LoginForm/Otp/index.tsx +89 -73
  128. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  129. package/themes/original/src/components/LoginForm/index.tsx +98 -41
  130. package/themes/original/src/components/LottieAnimation/index.tsx +69 -0
  131. package/themes/original/src/components/Messages/index.tsx +35 -20
  132. package/themes/original/src/components/MomentOption/index.tsx +8 -6
  133. package/themes/original/src/components/MultiCart/index.tsx +63 -0
  134. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +92 -93
  135. package/themes/original/src/components/MultiCheckout/index.tsx +10 -2
  136. package/themes/original/src/components/MultiOrdersDetails/index.tsx +34 -16
  137. package/themes/original/src/components/MyOrders/index.tsx +88 -22
  138. package/themes/original/src/components/NavBar/index.tsx +11 -5
  139. package/themes/original/src/components/NetworkError/index.tsx +5 -3
  140. package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
  141. package/themes/original/src/components/Notifications/index.tsx +148 -0
  142. package/themes/original/src/components/Notifications/styles.tsx +17 -0
  143. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  144. package/themes/original/src/components/OrderDetails/index.tsx +200 -39
  145. package/themes/original/src/components/OrderDetails/styles.tsx +15 -2
  146. package/themes/original/src/components/OrderItAgain/index.tsx +75 -0
  147. package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
  148. package/themes/original/src/components/OrderProgress/index.tsx +77 -66
  149. package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
  150. package/themes/original/src/components/OrderSummary/index.tsx +2 -35
  151. package/themes/original/src/components/OrderTypeSelector/index.tsx +85 -36
  152. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  153. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +94 -98
  154. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +3 -0
  155. package/themes/original/src/components/OrdersOption/index.tsx +101 -56
  156. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  157. package/themes/original/src/components/PaymentOptions/index.tsx +1 -2
  158. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  159. package/themes/original/src/components/PlaceSpot/index.tsx +249 -47
  160. package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
  161. package/themes/original/src/components/PreviousOrders/index.tsx +3 -2
  162. package/themes/original/src/components/ProductForm/index.tsx +639 -664
  163. package/themes/original/src/components/ProductForm/styles.tsx +10 -11
  164. package/themes/original/src/components/ProductItemAccordion/index.tsx +199 -128
  165. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  166. package/themes/original/src/components/ProductOptionSubOption/index.tsx +16 -8
  167. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +0 -1
  168. package/themes/original/src/components/ProfessionalFilter/index.tsx +2 -1
  169. package/themes/original/src/components/ProfessionalProfile/index.tsx +19 -8
  170. package/themes/original/src/components/Promotions/index.tsx +232 -219
  171. package/themes/original/src/components/Promotions/styles.tsx +7 -2
  172. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  173. package/themes/original/src/components/ReviewOrder/index.tsx +120 -108
  174. package/themes/original/src/components/ReviewOrder/styles.tsx +5 -7
  175. package/themes/original/src/components/ReviewProducts/index.tsx +8 -5
  176. package/themes/original/src/components/ReviewTrigger/index.tsx +136 -0
  177. package/themes/original/src/components/ReviewTrigger/styles.tsx +41 -0
  178. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  179. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  180. package/themes/original/src/components/ServiceForm/index.tsx +341 -267
  181. package/themes/original/src/components/SignupForm/index.tsx +160 -113
  182. package/themes/original/src/components/SingleOrderCard/index.tsx +266 -183
  183. package/themes/original/src/components/SingleOrderCard/styles.tsx +10 -8
  184. package/themes/original/src/components/SingleProductCard/index.tsx +198 -112
  185. package/themes/original/src/components/SingleProductCard/styles.tsx +3 -10
  186. package/themes/original/src/components/SingleProductReview/index.tsx +38 -5
  187. package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
  188. package/themes/original/src/components/StripeElementsForm/index.tsx +13 -2
  189. package/themes/original/src/components/UpsellingProducts/index.tsx +15 -5
  190. package/themes/original/src/components/UserDetails/index.tsx +5 -3
  191. package/themes/original/src/components/UserFormDetails/index.tsx +6 -48
  192. package/themes/original/src/components/UserProfile/index.tsx +56 -31
  193. package/themes/original/src/components/UserProfile/styles.ts +17 -0
  194. package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
  195. package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
  196. package/themes/original/src/components/Wallets/index.tsx +176 -164
  197. package/themes/original/src/components/Wallets/styles.tsx +12 -8
  198. package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
  199. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  200. package/themes/original/src/components/shared/OBottomPopup.tsx +48 -15
  201. package/themes/original/src/components/shared/OButton.tsx +10 -3
  202. package/themes/original/src/components/shared/OIcon.tsx +8 -1
  203. package/themes/original/src/components/shared/OInput.tsx +10 -1
  204. package/themes/original/src/layouts/Container.tsx +13 -9
  205. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  206. package/themes/original/src/types/index.tsx +86 -28
  207. package/themes/original/src/utils/index.tsx +103 -58
  208. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,17 +1,16 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import { StyleSheet, TouchableOpacity, View, Platform, PlatformIOSStatic } from 'react-native';
2
+ import { View } from 'react-native';
3
3
  import { useTheme } from 'styled-components/native';
4
- import moment from 'moment'
5
- import { useLanguage, useUtils, useConfig } from 'ordering-components/native';
6
- import { OButton, OIcon, OText } from '../shared';
7
- import {
8
- Card, Logo, Information, MyOrderOptions, NotificationIcon, AcceptOrRejectOrder, Timestatus
9
- } from './styles';
10
- import EntypoIcon from 'react-native-vector-icons/Entypo'
11
- import { DeviceOrientationMethods } from '../../../../../src/hooks/DeviceOrientation'
12
- import DeviceInfo from 'react-native-device-info';
4
+ import { useLanguage } from 'ordering-components/native';
13
5
 
14
- const { useDeviceOrientation, PORTRAIT } = DeviceOrientationMethods
6
+ import {AcceptOrRejectOrder as AcceptOrRejectOrderStyle } from './styles';
7
+
8
+ import { OButton, OModal } from '../shared';
9
+ import { OrderItem } from './OrderItem'
10
+ import { OrdersGroupedItem } from './OrdersGroupedItem'
11
+ import { AcceptOrRejectOrder } from '../AcceptOrRejectOrder';
12
+ import { ReviewCustomer } from '../ReviewCustomer';
13
+ import { GoogleMap } from '../GoogleMap';
15
14
 
16
15
  export const PreviousOrders = (props: any) => {
17
16
  const {
@@ -23,25 +22,23 @@ export const PreviousOrders = (props: any) => {
23
22
  handleClickLogisticOrder,
24
23
  slaSettingTime,
25
24
  currentTabSelected,
26
- currentOrdenSelected
25
+ currentOrdenSelected,
26
+ handleChangeOrderStatus,
27
+ handleSendCustomerReview
27
28
  } = props;
29
+
30
+ let hash: any = {};
28
31
  const [, t] = useLanguage();
29
- const [{ parseDate, optimizeImage }] = useUtils();
30
- const [configState] = useConfig()
31
32
  const theme = useTheme();
32
- const [, setCurrentTime] = useState()
33
- const [allowColumns, setAllowColumns] = useState({
34
- timer: true,
35
- slaBar: true,
36
- })
37
-
38
- const [orientationState] = useDeviceOrientation();
39
33
 
40
- const IS_PORTRAIT = orientationState.orientation === PORTRAIT
34
+ const [, setCurrentTime] = useState()
35
+ const [openModal, setOpenModal] = useState(false)
36
+ const [openReviewModal, setOpenReviewModal] = useState({ order: null, ids: [], customerId: null })
37
+ const [openMapViewModal, setOpenMapViewModal] = useState<any>({ open: false, customerLocation: null, locations: [] })
38
+ const [orderUpdateStatus, setOrderUpdateStatus] = useState<any>({ action: '', ids: [], body: {}, order: {} })
41
39
 
42
- const platformIOS = Platform as PlatformIOSStatic
43
- const isIpad = platformIOS.isPad
44
- const isTablet = DeviceInfo.isTablet();
40
+ const pastOrderStatuses = [1, 2, 5, 6, 10, 11, 12, 16, 17]
41
+ const viewMapStatus = [9, 18, 19, 23]
45
42
 
46
43
  const handlePressOrder = (order: any) => {
47
44
  if (order?.locked && isLogisticOrder) return
@@ -54,251 +51,342 @@ export const PreviousOrders = (props: any) => {
54
51
  }
55
52
  };
56
53
 
57
- const styles = StyleSheet.create({
58
- cardButton: {
59
- flex: 1,
60
- paddingVertical: (isIpad || isTablet) ? 20 : 0,
61
- marginBottom: IS_PORTRAIT ? 25 : 0,
62
- marginLeft: 3,
63
- },
64
- icon: {
65
- borderRadius: 7.6,
66
- width: 60,
67
- height: 60
68
- },
69
- logo: {
70
- borderRadius: 10,
71
- shadowColor: "#0000006e",
72
- shadowRadius: 10,
73
- elevation: 15,
74
- justifyContent: 'center',
75
- alignItems: 'center',
76
- marginLeft: 3,
77
- },
78
- title: {
79
- marginBottom: 6,
80
- fontFamily: 'Poppins',
81
- fontStyle: 'normal',
82
- fontWeight: '600',
83
- fontSize: 16,
84
- color: theme.colors.textGray,
85
- },
86
- date: {
87
- marginBottom: 6,
88
- fontFamily: 'Poppins',
89
- fontStyle: 'normal',
90
- fontWeight: 'normal',
91
- fontSize: 12,
92
- },
93
- orderType: {
94
- fontSize: 12,
95
- fontFamily: 'Poppins',
96
- fontStyle: 'normal',
97
- fontWeight: 'normal',
98
- color: theme.colors.orderTypeColor,
99
- },
100
- });
54
+ const OrdersList = (props: any) => {
55
+ const { order, _order, hideBtns } = props
56
+ return (
57
+ <View
58
+ style={{
59
+ backgroundColor: currentOrdenSelected === order?.id ? theme.colors.gray100 : order?.locked && isLogisticOrder ? '#ccc' : '#fff',
60
+ marginBottom: isLogisticOrder ? 10 : 0
61
+ }}
62
+ >
63
+ <OrderItem
64
+ order={order}
65
+ _order={_order}
66
+ isLogisticOrder={isLogisticOrder}
67
+ handlePressOrder={handlePressOrder}
68
+ currentTabSelected={currentTabSelected}
69
+ getOrderStatus={getOrderStatus}
70
+ />
71
+ {isLogisticOrder && !hideBtns && (
72
+ <AcceptOrRejectOrderStyle>
73
+ {!!order?.order_group_id && !!order?.order_group ? (
74
+ <OButton
75
+ text={t('VIEW_ORDER', 'View order')}
76
+ onClick={() => handlePressOrder({ ...order, logistic_order_id: _order?.id })}
77
+ bgColor={theme.colors.blueLight}
78
+ borderColor={theme.colors.blueLight}
79
+ imgRightSrc={null}
80
+ style={{ borderRadius: 7, height: 40 }}
81
+ parentStyle={{ width: '100%' }}
82
+ textStyle={{ color: theme.colors.primary }}
83
+ />
84
+ ) : (
85
+ <>
86
+ <OButton
87
+ text={t('REJECT', 'Reject')}
88
+ onClick={() => handleClickLogisticOrder(2, _order?.id)}
89
+ bgColor={theme.colors.danger}
90
+ borderColor={theme.colors.danger}
91
+ imgRightSrc={null}
92
+ style={{ borderRadius: 7, height: 40 }}
93
+ parentStyle={{ width: '45%' }}
94
+ textStyle={{ color: theme.colors.dangerText }}
95
+ />
96
+ <OButton
97
+ text={t('ACCEPT', 'Accept')}
98
+ onClick={() => handleClickLogisticOrder(1, _order?.id)}
99
+ bgColor={theme.colors.successOrder}
100
+ borderColor={theme.colors.successOrder}
101
+ imgRightSrc={null}
102
+ style={{ borderRadius: 7, height: 40 }}
103
+ parentStyle={{ width: '45%' }}
104
+ textStyle={{ color: theme.colors.successText }}
105
+ />
106
+ </>
107
+ )}
108
+ </AcceptOrRejectOrderStyle>
109
+ )}
110
+ </View>
111
+ )
112
+ }
101
113
 
102
- const getDelayMinutes = (order: any) => {
103
- // targetMin = delivery_datetime + eta_time - now()
104
- const offset = 300
105
- const cdtToutc = moment(order?.delivery_datetime).add(offset, 'minutes').format('YYYY-MM-DD HH:mm:ss')
106
- const _delivery = order?.delivery_datetime_utc
107
- ? parseDate(order?.delivery_datetime_utc, { outputFormat: 'YYYY-MM-DD hh:mm A' })
108
- : parseDate(cdtToutc, { outputFormat: 'YYYY-MM-DD hh:mm A' })
109
- const _eta = order?.eta_time
110
- const diffTimeAsSeconds = moment(_delivery, 'YYYY-MM-DD hh:mm A').add(_eta, 'minutes').diff(moment().utc(), 'seconds')
111
- return Math.ceil(diffTimeAsSeconds / 60)
114
+ const ordersGroupAction = (param1 = '', param2 = '', { order, action, body, ids }: any = {}) => {
115
+ setOrderUpdateStatus({ ...orderUpdateStatus, action, ids, body, order })
116
+ if (!param1) setOpenModal(true)
117
+ if (param1) {
118
+ setOpenModal(false)
119
+ handleChangeOrderStatus &&
120
+ handleChangeOrderStatus(param1, orderUpdateStatus.ids, param2)
121
+ }
112
122
  }
113
123
 
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)
119
- let day: string | number = Math.floor(tagetedMin / 1440)
120
- const restMinOfTargetedMin = tagetedMin - 1440 * day
121
- let restHours: string | number = Math.floor(restMinOfTargetedMin / 60)
122
- let restMins: string | number = 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
124
+ const handleOpenMapView = ({ orders }: any) => {
125
+ const locations: any = []
127
126
 
128
- const finalTaget = sign + day + restHours + ':' + restMins
129
- return finalTaget
130
- }
127
+ orders.map((_order: any) => {
128
+ if (_order?.driver?.location) {
129
+ locations.push({
130
+ ..._order?.driver?.location,
131
+ title: _order?.driver?.name ?? t('DRIVER', 'Driver'),
132
+ icon:
133
+ _order?.driver?.photo ||
134
+ 'https://res.cloudinary.com/demo/image/fetch/c_thumb,g_face,r_max/https://www.freeiconspng.com/thumbs/driver-icon/driver-icon-14.png',
135
+ level: 4,
136
+ })
137
+ }
138
+ if (_order?.business?.location) {
139
+ locations.push({
140
+ ..._order?.business?.location,
141
+ title: _order?.business?.name,
142
+ address: {
143
+ addressName: _order?.business?.address,
144
+ zipcode: _order?.business?.zipcode
145
+ },
146
+ icon:
147
+ _order?.business?.logo ||
148
+ 'https://res.cloudinary.com/demo/image/fetch/c_thumb,g_face,r_max/https://res.cloudinary.com/ordering2/image/upload/v1654619525/hzegwosnplvrbtjkpfi6.png',
149
+ level: 2,
150
+ })
151
+ }
152
+ if (_order?.customer?.location) {
153
+ locations.push({
154
+ ..._order?.customer?.location,
155
+ title: _order?.customer?.name ?? t('CUSTOMER', 'Customer'),
156
+ address: {
157
+ addressName: _order?.customer?.address,
158
+ zipcode: _order?.customer?.zipcode
159
+ },
160
+ icon:
161
+ _order?.customer?.photo ||
162
+ 'https://res.cloudinary.com/demo/image/upload/c_thumb,g_face,r_max/d_avatar.png/non_existing_id.png',
163
+ level: 3,
164
+ })
165
+ }
166
+ })
131
167
 
132
- const getStatusClassName = (minutes: number) => {
133
- if (isNaN(Number(minutes))) return 'in_time'
134
- const delayTime = configState?.configs?.order_deadlines_delayed_time?.value
135
- return minutes > 0 ? 'in_time' : Math.abs(minutes) <= delayTime ? 'at_risk' : 'delayed'
168
+ setOpenMapViewModal({
169
+ ...openMapViewModal,
170
+ open: true,
171
+ locations,
172
+ customerLocation: orders[0]?.customer?.location
173
+ })
136
174
  }
137
175
 
138
176
  useEffect(() => {
139
177
  const interval = setInterval(() => {
140
178
  const date: any = Date.now()
141
179
  setCurrentTime(date)
142
- }, slaSettingTime)
180
+ }, slaSettingTime ?? 6000)
143
181
 
144
182
  return () => clearInterval(interval)
145
183
  }, [])
146
184
 
147
- useEffect(() => {
148
- const slaSettings = configState?.configs?.order_deadlines_enabled?.value === '1'
149
- setAllowColumns({
150
- ...allowColumns,
151
- timer: slaSettings,
152
- slaBar: slaSettings
153
- })
154
- }, [configState.loading])
155
-
156
- let hash: any = {};
157
185
 
158
186
  return (
159
187
  <>
160
- {orders && orders?.length > 0 &&
161
- orders
162
- ?.filter((order: any) => hash[order?.id] ? false : (hash[order?.id] = true))
163
- ?.map((_order: any) => {
164
- const order = _order?.isLogistic && !_order?.order_group && isLogisticOrder ? _order?.order : _order
165
- return (
166
- <View
167
- style={{
168
- backgroundColor: currentOrdenSelected === order?.id ? theme.colors.gray100 : order?.locked && isLogisticOrder ? '#ccc' : '#fff',
169
- marginBottom: isLogisticOrder ? 10 : 0,
170
- // justifyContent: 'center'
171
- }}
172
- key={order.id}
173
- >
174
- <TouchableOpacity
175
- onPress={() => handlePressOrder({ ...order, logistic_order_id: _order?.id })}
176
- style={styles.cardButton}
177
- disabled={order?.locked && isLogisticOrder}
178
- activeOpacity={1}
188
+ {orders && orders?.length > 0 && orders.map((_order: any) => {
189
+ const order = !Array.isArray(_order) && (_order?.isLogistic && !_order?.order_group && isLogisticOrder ? _order?.order : _order)
190
+ const _ordersGrouped = Array.isArray(_order) && Object.fromEntries(_order)
191
+ return (
192
+ _ordersGrouped ? (
193
+ <View key={_order[0]} style={{ marginBottom: 10 }}>
194
+ {Object.keys(_ordersGrouped).map((k, idx) => (
195
+ <OrdersGroupedItem
196
+ key={`${k}_${idx}`}
197
+ groupId={k}
198
+ orders={_ordersGrouped[k]}
179
199
  >
180
- <Card key={order.id}>
181
- {allowColumns?.slaBar && (
182
- <Timestatus style={{ backgroundColor: getStatusClassName(getDelayMinutes(order)) === 'in_time' ? '#00D27A' : getStatusClassName(getDelayMinutes(order)) === 'at_risk' ? '#FFC700' : getStatusClassName(getDelayMinutes(order)) === 'delayed' ? '#E63757' : '' }} />
183
- )}
184
- {
185
- !!order.business?.logo && (
186
- <Logo style={styles.logo}>
187
- <OIcon
188
- url={optimizeImage(
189
- order.business?.logo,
190
- 'h_300,c_limit',
191
- )}
192
- style={styles.icon}
193
- />
194
- </Logo>
195
- )}
196
- <Information>
197
- {!!order?.order_group_id && (
198
- <OText>
199
- <OText>{(t('INVOICE_GROUP_NO', 'Group No.') + order?.order_group_id)}</OText>
200
- </OText>
201
- )}
202
- {!!order.business?.name && (
203
- <OText numberOfLines={1} style={styles.title}>
204
- {order.business?.name}
205
- </OText>
206
- )}
207
- {!!order?.showNotification && (
208
- <NotificationIcon>
209
- <EntypoIcon
210
- name="dot-single"
211
- size={32}
212
- color={theme.colors.primary}
213
- />
214
- </NotificationIcon>
215
- )}
216
- <View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
217
- <OText
218
- style={styles.date}
219
- color={theme.colors.unselectText}
220
- numberOfLines={1}
221
- adjustsFontSizeToFit
222
- >
223
- {(order?.order_group_id && order?.order_group && isLogisticOrder ? `${order?.order_group?.orders?.length} ${t('ORDERS', 'Orders')}` : (t('NO', 'Order No.') + order.id)) + ' · '}
224
- {order?.delivery_datetime_utc
225
- ? parseDate(order?.delivery_datetime_utc, { outputFormat: 'MM/DD/YY · HH:mm a' })
226
- : parseDate(order?.delivery_datetime, { utc: false })}
227
- </OText>
228
- {((currentTabSelected === 'pending' || currentTabSelected === 'inProgress') && allowColumns?.timer) && (
229
- <>
230
- <OText> · </OText>
231
- <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>
232
- </>
200
+ {_ordersGrouped[k]?.length > 0 &&
201
+ _ordersGrouped[k]
202
+ ?.filter((order: any) => hash[order?.id] ? false : (hash[order?.id] = true))
203
+ ?.map((_order: any) => {
204
+ const order_ = _order?.isLogistic && !_order?.order_group && isLogisticOrder ? _order?.order : _order
205
+ return (
206
+ <OrdersList key={order_.id} order={order_} _order={_order} hideBtns />
207
+ )
208
+ }
209
+ )
210
+ }
211
+ {_ordersGrouped[k][0]?.status === 0 && (
212
+ <AcceptOrRejectOrderStyle>
213
+ <OButton
214
+ text={t('REJECT_ALL', 'Reject all')}
215
+ bgColor={theme.colors.danger100}
216
+ borderColor={theme.colors.danger100}
217
+ imgRightSrc={null}
218
+ style={{ borderRadius: 7, height: 40 }}
219
+ parentStyle={{ width: '45%' }}
220
+ textStyle={{ color: theme.colors.danger500, fontSize: 12 }}
221
+ onClick={() => onNavigationRedirect('AcceptOrRejectOrder', {
222
+ action: 'reject',
223
+ order: _ordersGrouped[k][0],
224
+ ids: _ordersGrouped[k].map((o: any) => o.id),
225
+ handleChangeOrderStatus
226
+ })}
227
+ />
228
+ <OButton
229
+ text={t('ACCEPT_ALL', 'Accept all')}
230
+ bgColor={theme.colors.success100}
231
+ borderColor={theme.colors.success100}
232
+ imgRightSrc={null}
233
+ style={{ borderRadius: 7, height: 40 }}
234
+ parentStyle={{ width: '45%' }}
235
+ textStyle={{ color: theme.colors.success500, fontSize: 12 }}
236
+ onClick={() => onNavigationRedirect('AcceptOrRejectOrder', {
237
+ action: 'accept',
238
+ order: _ordersGrouped[k][0],
239
+ ids: _ordersGrouped[k].map((o: any) => o.id),
240
+ handleChangeOrderStatus
241
+ })}
242
+ />
243
+ </AcceptOrRejectOrderStyle>
244
+ )}
245
+ <View>
246
+ {_ordersGrouped[k][0]?.status === 7 && (
247
+ <OButton
248
+ text={t('READY_FOR_PICKUP', 'Ready for pickup')}
249
+ bgColor={theme.colors.primaryLight}
250
+ borderColor={theme.colors.primaryLight}
251
+ imgRightSrc={null}
252
+ style={{ borderRadius: 7, height: 40 }}
253
+ parentStyle={{ width: '100%' }}
254
+ textStyle={{ color: theme.colors.primary, fontSize: 12 }}
255
+ onClick={() => handleChangeOrderStatus(
256
+ 4,
257
+ _ordersGrouped[k].map((o: any) => o.id),
233
258
  )}
234
- </View>
235
- {!isLogisticOrder && (
236
- <MyOrderOptions>
237
- <OText
238
- style={styles.orderType}
239
- mRight={5}
240
- numberOfLines={1}
241
- adjustsFontSizeToFit
242
- >
243
- {order.delivery_type === 1
244
- ? t('DELIVERY', 'Delivery')
245
- : order.delivery_type === 2
246
- ? t('PICKUP', 'Pickup')
247
- : order.delivery_type === 3
248
- ? t('EAT_IN', 'Eat in')
249
- : order.delivery_type === 4
250
- ? t('CURBSIDE', 'Curbside')
251
- : t('DRIVER_THRU', 'Driver thru')}
252
- {` · ${getOrderStatus(order.status)}`}
253
- </OText>
254
- </MyOrderOptions>
255
- )}
256
- </Information>
257
- </Card>
258
- </TouchableOpacity>
259
- {isLogisticOrder && (
260
- <AcceptOrRejectOrder>
261
- {!!order?.order_group_id && !!order?.order_group ? (
259
+ />
260
+ )}
261
+ </View>
262
+ <View>
263
+ {viewMapStatus.includes(_ordersGrouped[k][0]?.status) && (
262
264
  <OButton
263
- text={t('VIEW_ORDER', 'View order')}
264
- onClick={() => handlePressOrder({ ...order, logistic_order_id: _order?.id })}
265
- bgColor={theme.colors.blueLight}
266
- borderColor={theme.colors.blueLight}
265
+ text={t('TRACK_REAL_TIME_POSITION', 'Track real time position')}
266
+ bgColor={theme.colors.primaryLight}
267
+ borderColor={theme.colors.primaryLight}
267
268
  imgRightSrc={null}
268
269
  style={{ borderRadius: 7, height: 40 }}
269
270
  parentStyle={{ width: '100%' }}
270
- textStyle={{ color: theme.colors.primary }}
271
+ textStyle={{ color: theme.colors.primary, fontSize: 12 }}
272
+ onClick={() => handleOpenMapView({ orders: _ordersGrouped[k] })}
271
273
  />
272
- ) : (
273
- <>
274
- <OButton
275
- text={t('REJECT', 'Reject')}
276
- onClick={() => handleClickLogisticOrder(2, _order?.id)}
277
- bgColor={theme.colors.danger}
278
- borderColor={theme.colors.danger}
279
- imgRightSrc={null}
280
- style={{ borderRadius: 7, height: 40 }}
281
- parentStyle={{ width: '45%' }}
282
- textStyle={{ color: theme.colors.dangerText }}
283
- />
284
- <OButton
285
- text={t('ACCEPT', 'Accept')}
286
- onClick={() => handleClickLogisticOrder(1, _order?.id)}
287
- bgColor={theme.colors.successOrder}
288
- borderColor={theme.colors.successOrder}
289
- imgRightSrc={null}
290
- style={{ borderRadius: 7, height: 40 }}
291
- parentStyle={{ width: '45%' }}
292
- textStyle={{ color: theme.colors.successText }}
293
- />
294
- </>
295
274
  )}
296
- </AcceptOrRejectOrder>
297
- )}
298
- </View>
299
- )
300
- }
301
- )}
275
+ </View>
276
+ {_ordersGrouped[k][0]?.status === 4 &&
277
+ ![1].includes(_ordersGrouped[k][0]?.delivery_type) &&
278
+ (
279
+ <AcceptOrRejectOrderStyle>
280
+ <OButton
281
+ text={t('ORDER_NOT_PICKEDUP_BY_CUSTOMER', 'Order not picked up by customer')}
282
+ bgColor={theme.colors.danger100}
283
+ borderColor={theme.colors.danger100}
284
+ imgRightSrc={null}
285
+ style={{ borderRadius: 7, height: 40, paddingLeft: 10, paddingRight: 10 }}
286
+ parentStyle={{ width: '45%' }}
287
+ textStyle={{ color: theme.colors.danger500, fontSize: 12, textAlign: 'center' }}
288
+ onClick={() => handleChangeOrderStatus(
289
+ 17,
290
+ _ordersGrouped[k].map((o: any) => o.id),
291
+ )}
292
+ />
293
+ <OButton
294
+ text={t('PICKUP_COMPLETED_BY_CUSTOMER', 'Pickup completed by customer')}
295
+ bgColor={theme.colors.success100}
296
+ borderColor={theme.colors.success100}
297
+ imgRightSrc={null}
298
+ style={{ borderRadius: 7, height: 40, paddingLeft: 10, paddingRight: 10 }}
299
+ parentStyle={{ width: '45%' }}
300
+ textStyle={{ color: theme.colors.success500, fontSize: 12, textAlign: 'center' }}
301
+ onClick={() => handleChangeOrderStatus(
302
+ 15,
303
+ _ordersGrouped[k].map((o: any) => o.id),
304
+ )}
305
+ />
306
+ </AcceptOrRejectOrderStyle>
307
+ )}
308
+ {!_ordersGrouped[k][0]?.user_review &&
309
+ pastOrderStatuses.includes(_ordersGrouped[k][0]?.status) &&
310
+ (
311
+ <OButton
312
+ text={t('REVIEW_CUSTOMER', 'Review customer')}
313
+ bgColor={theme.colors.primary}
314
+ borderColor={theme.colors.primary}
315
+ imgRightSrc={null}
316
+ style={{ borderRadius: 8, height: 40 }}
317
+ parentStyle={{ width: '100%' }}
318
+ textStyle={{ color: theme.colors.white }}
319
+ onClick={() => setOpenReviewModal({
320
+ order: _ordersGrouped[k][0],
321
+ customerId: _ordersGrouped[k][0]?.customer_id,
322
+ ids: _ordersGrouped[k].map((o: any) => o.id)
323
+ })}
324
+ />
325
+ )}
326
+ </OrdersGroupedItem>
327
+ ))}
328
+ </View>
329
+ ) : (
330
+ <View key={order.id}>
331
+ <OrdersList order={order} _order={_order} />
332
+ </View>
333
+ )
334
+ )
335
+ })}
336
+
337
+ <OModal
338
+ open={openModal}
339
+ onClose={() => setOpenModal(false)}
340
+ entireModal
341
+ customClose
342
+ >
343
+ <AcceptOrRejectOrder
344
+ notShowCustomerPhone={false}
345
+ appTitle={props.appTitle}
346
+ customerCellphone={orderUpdateStatus.order?.customer?.cellphone}
347
+ action={orderUpdateStatus.action}
348
+ orderId={orderUpdateStatus.ids?.[0]}
349
+ actions={props.actions}
350
+ orderTitle={props.orderTitle}
351
+ handleUpdateOrder={ordersGroupAction}
352
+ closeModal={() => setOpenModal(false)}
353
+ />
354
+ </OModal>
355
+ <OModal
356
+ open={!!openReviewModal?.order}
357
+ onClose={() => setOpenReviewModal({ order: null, ids: [], customerId: null })}
358
+ entireModal
359
+ customClose
360
+ >
361
+ <ReviewCustomer
362
+ order={openReviewModal?.order}
363
+ closeModal={() => setOpenReviewModal({ order: null, ids: [], customerId: null })}
364
+ onClose={() => setOpenReviewModal({ order: null, ids: [], customerId: null })}
365
+ handleCustomCustomerReview={(body: any) => handleSendCustomerReview({
366
+ onClose: setOpenReviewModal({ order: null, ids: [], customerId: null }),
367
+ customerId: openReviewModal?.customerId,
368
+ orderIds: openReviewModal?.ids,
369
+ body
370
+ })}
371
+ />
372
+ </OModal>
373
+ <OModal
374
+ open={openMapViewModal.open}
375
+ onClose={() => setOpenMapViewModal({ ...openMapViewModal, open: false })}
376
+ entireModal
377
+ customClose
378
+ >
379
+ <GoogleMap
380
+ readOnly
381
+ navigation={props.navigation}
382
+ location={openMapViewModal.customerLocation}
383
+ locations={openMapViewModal.locations}
384
+ handleOpenMapView={() => setOpenMapViewModal({
385
+ ...openMapViewModal,
386
+ open: !openMapViewModal
387
+ })}
388
+ />
389
+ </OModal>
302
390
  </>
303
391
  );
304
392
  };