ordering-ui-react-native 0.15.51 → 0.15.53-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 (189) hide show
  1. package/package.json +5 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/AddressForm/index.tsx +18 -2
  4. package/src/components/BusinessController/index.tsx +16 -8
  5. package/src/components/BusinessTypeFilter/index.tsx +3 -1
  6. package/src/components/BusinessesListing/index.tsx +1 -1
  7. package/src/components/Checkout/index.tsx +23 -2
  8. package/src/components/DriverTips/index.tsx +11 -6
  9. package/src/components/LanguageSelector/index.tsx +7 -2
  10. package/src/components/LoginForm/index.tsx +120 -30
  11. package/src/components/LoginForm/styles.tsx +6 -0
  12. package/src/components/OrderDetails/index.tsx +9 -23
  13. package/src/components/PaymentOptions/index.tsx +67 -50
  14. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  15. package/src/components/SignupForm/index.tsx +145 -61
  16. package/src/components/SingleProductCard/index.tsx +16 -4
  17. package/src/components/StripeMethodForm/index.tsx +1 -2
  18. package/src/components/UpsellingProducts/index.tsx +1 -1
  19. package/src/components/UserProfileForm/index.tsx +63 -6
  20. package/src/components/UserProfileForm/styles.tsx +8 -0
  21. package/src/components/VerifyPhone/styles.tsx +1 -2
  22. package/src/components/shared/OModal.tsx +1 -1
  23. package/src/hooks/useCountdownTimer.tsx +26 -0
  24. package/src/navigators/CheckoutNavigator.tsx +6 -0
  25. package/src/navigators/HomeNavigator.tsx +12 -0
  26. package/src/pages/BusinessesListing.tsx +1 -1
  27. package/src/pages/MultiCheckout.tsx +31 -0
  28. package/src/pages/MultiOrdersDetails.tsx +27 -0
  29. package/src/pages/Sessions.tsx +22 -0
  30. package/src/theme.json +0 -1
  31. package/src/types/index.tsx +18 -11
  32. package/src/utils/index.tsx +68 -1
  33. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  34. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  35. package/themes/business/src/components/Chat/index.tsx +42 -90
  36. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  37. package/themes/business/src/components/Home/index.tsx +128 -55
  38. package/themes/business/src/components/Home/styles.tsx +8 -1
  39. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  40. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  41. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  42. package/themes/business/src/components/NewOrderNotification/index.tsx +79 -105
  43. package/themes/business/src/components/OrderDetails/Business.tsx +2 -2
  44. package/themes/business/src/components/OrderDetails/Delivery.tsx +35 -18
  45. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +159 -91
  46. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  47. package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
  48. package/themes/business/src/components/OrdersListManager/index.tsx +1 -1
  49. package/themes/business/src/components/OrdersOption/index.tsx +5 -2
  50. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  51. package/themes/business/src/components/shared/OModal.tsx +1 -1
  52. package/themes/business/src/types/index.tsx +5 -1
  53. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  54. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  55. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  56. package/themes/kiosk/src/components/BusinessMenu/index.tsx +39 -28
  57. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  58. package/themes/kiosk/src/components/Cart/index.tsx +99 -26
  59. package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
  60. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  61. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  62. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  63. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  64. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  65. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  66. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  67. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  68. package/themes/kiosk/src/components/NavBar/index.tsx +29 -20
  69. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  70. package/themes/kiosk/src/components/OrderDetails/index.tsx +165 -65
  71. package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
  72. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  73. package/themes/kiosk/src/components/PaymentOptions/index.tsx +56 -54
  74. package/themes/kiosk/src/components/ProductForm/index.tsx +7 -8
  75. package/themes/kiosk/src/components/ProductItemAccordion/index.tsx +2 -2
  76. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -1
  77. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  78. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  79. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  80. package/themes/kiosk/src/types/index.d.ts +3 -0
  81. package/themes/original/index.tsx +169 -4
  82. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  83. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  84. package/themes/original/src/components/AddressForm/index.tsx +1 -1
  85. package/themes/original/src/components/AddressList/index.tsx +30 -18
  86. package/themes/original/src/components/AppleLogin/index.tsx +54 -21
  87. package/themes/original/src/components/BusinessBasicInformation/index.tsx +136 -45
  88. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +4 -0
  89. package/themes/original/src/components/BusinessController/index.tsx +48 -11
  90. package/themes/original/src/components/BusinessController/styles.tsx +27 -0
  91. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  92. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  93. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
  94. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  95. package/themes/original/src/components/BusinessListingSearch/index.tsx +196 -58
  96. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  97. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  98. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  99. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  100. package/themes/original/src/components/BusinessProductsList/index.tsx +119 -35
  101. package/themes/original/src/components/BusinessProductsList/styles.tsx +12 -4
  102. package/themes/original/src/components/BusinessProductsListing/index.tsx +109 -21
  103. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
  104. package/themes/original/src/components/BusinessReviews/index.tsx +10 -26
  105. package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
  106. package/themes/original/src/components/BusinessesListing/index.tsx +127 -66
  107. package/themes/original/src/components/BusinessesListing/styles.tsx +11 -3
  108. package/themes/original/src/components/Cart/index.tsx +60 -41
  109. package/themes/original/src/components/Checkout/index.tsx +48 -32
  110. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  111. package/themes/original/src/components/Favorite/index.tsx +92 -0
  112. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  113. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  114. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  115. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  116. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  117. package/themes/original/src/components/GoogleMap/index.tsx +1 -0
  118. package/themes/original/src/components/Help/index.tsx +21 -4
  119. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  120. package/themes/original/src/components/Home/index.tsx +1 -1
  121. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  122. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
  123. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  124. package/themes/original/src/components/LoginForm/index.tsx +332 -164
  125. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  126. package/themes/original/src/components/LogoutButton/index.tsx +7 -1
  127. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  128. package/themes/original/src/components/Messages/index.tsx +1 -1
  129. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  130. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  131. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  132. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  133. package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
  134. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  135. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  136. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  137. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  138. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  139. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  140. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  141. package/themes/original/src/components/OrderDetails/index.tsx +117 -46
  142. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  143. package/themes/original/src/components/OrderSummary/index.tsx +3 -3
  144. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  145. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  146. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  147. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  148. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  149. package/themes/original/src/components/OrdersOption/index.tsx +130 -38
  150. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  151. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  152. package/themes/original/src/components/PaymentOptionWallet/index.tsx +17 -23
  153. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  154. package/themes/original/src/components/PaymentOptions/index.tsx +57 -36
  155. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  156. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  157. package/themes/original/src/components/ProductForm/index.tsx +70 -62
  158. package/themes/original/src/components/ProductForm/styles.tsx +0 -1
  159. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  160. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  161. package/themes/original/src/components/Promotions/index.tsx +151 -133
  162. package/themes/original/src/components/Promotions/styles.tsx +3 -23
  163. package/themes/original/src/components/SearchBar/index.tsx +10 -4
  164. package/themes/original/src/components/Sessions/index.tsx +160 -0
  165. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  166. package/themes/original/src/components/SignupForm/index.tsx +333 -128
  167. package/themes/original/src/components/SingleOrderCard/index.tsx +282 -0
  168. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  169. package/themes/original/src/components/SingleProductCard/index.tsx +59 -17
  170. package/themes/original/src/components/StripeElementsForm/index.tsx +16 -8
  171. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  172. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  173. package/themes/original/src/components/UserDetails/index.tsx +5 -96
  174. package/themes/original/src/components/UserFormDetails/index.tsx +34 -24
  175. package/themes/original/src/components/UserProfile/index.tsx +53 -6
  176. package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
  177. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  178. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  179. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  180. package/themes/original/src/components/Wallets/index.tsx +76 -9
  181. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  182. package/themes/original/src/components/shared/OModal.tsx +4 -2
  183. package/themes/original/src/config/constants.tsx +6 -6
  184. package/themes/original/src/types/index.tsx +139 -15
  185. package/themes/original/src/utils/index.tsx +85 -2
  186. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  187. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
  188. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
  189. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,56 +1,144 @@
1
1
  import React, { useState, useEffect } from 'react'
2
2
  import { useLanguage } from 'ordering-components/native';
3
- import { View, StyleSheet, Platform, I18nManager } from 'react-native';
3
+ import { View, StyleSheet, RefreshControl } from 'react-native';
4
4
 
5
5
  import { OrdersOption } from '../OrdersOption'
6
- import { OText } from '../shared'
6
+ import { HeaderTitle, OText } from '../shared'
7
7
  import { ScrollView } from 'react-native-gesture-handler';
8
-
9
- const PIXELS_TO_SCROLL = 1000;
8
+ import { Tab } from './styles'
9
+ import { useTheme } from 'styled-components/native';
10
+ import { Container } from '../../layouts/Container';
10
11
 
11
12
  export const MyOrders = (props: any) => {
12
- const [, t] = useLanguage();
13
- const [loadMore, setLoadMore] = useState(false)
14
-
13
+ const {
14
+ hideOrders,
15
+ businessesSearchList
16
+ } = props
17
+ const [, t] = useLanguage()
18
+ const theme = useTheme()
19
+ const [refreshing] = useState(false);
20
+ const [refreshOrders, setRefreshOrders] = useState(false)
21
+ const [isEmptyBusinesses, setIsEmptyBusinesses] = useState(false)
22
+ const [businessOrderIds, setBusinessOrderIds] = useState([])
15
23
  const [ordersLength, setOrdersLength] = useState({
16
24
  activeOrdersLength: 0,
17
25
  previousOrdersLength: 0,
18
26
  });
27
+ const [selectedOption, setSelectedOption] = useState(!hideOrders ? 'orders' : 'business')
28
+
29
+ const notOrderOptions = ['business', 'products']
30
+ const allEmpty = (ordersLength?.activeOrdersLength === 0 && ordersLength?.previousOrdersLength === 0) || ((isEmptyBusinesses || businessOrderIds?.length === 0) && hideOrders)
31
+ const MyOrdersMenu = [
32
+ { key: 'orders', value: t('ORDERS', 'Orders') },
33
+ { key: 'business', value: t('BUSINESS', 'Business') },
34
+ { key: 'products', value: t('PRODUCTS', 'Products') }
35
+ ]
19
36
 
20
- const handleScroll = ({ nativeEvent }: any) => {
21
- const y = nativeEvent.contentOffset.y
22
- const height = nativeEvent.contentSize.height
37
+ const handleOnRefresh = () => {
38
+ setRefreshOrders(true);
39
+ }
23
40
 
24
- if (y + PIXELS_TO_SCROLL > height ) {
25
- setLoadMore(true)
41
+ const styles = StyleSheet.create({
42
+ container: {
43
+ paddingVertical: 5,
44
+ borderColor: theme.colors.clear,
45
+ backgroundColor: '#FFF'
46
+ },
47
+ featuredStyle: {
48
+ display: 'none',
49
+ },
50
+ tabStyle: {
51
+ marginTop: 10,
52
+ height: 4,
53
+ borderTopStartRadius: 4,
54
+ borderTopEndRadius: 4,
55
+ backgroundColor: theme.colors.textPrimary,
56
+ },
57
+ tabDeactived: {
58
+ marginTop: 10,
59
+ height: 4
26
60
  }
27
- }
61
+ });
28
62
 
29
63
  return (
30
- <ScrollView onScroll={(e: any) => handleScroll(e)}>
31
- <OText
32
- size={20}
33
- mBottom={15}
34
- style={{ marginTop: 25, paddingHorizontal: 40 }}>
35
- {t('MY_ORDERS', 'My Orders')}
36
- </OText>
37
- <View style={{ paddingLeft: 40, paddingRight: 40 }}>
64
+ <Container noPadding refreshControl={
65
+ <RefreshControl
66
+ refreshing={refreshing}
67
+ onRefresh={() => handleOnRefresh()}
68
+ />
69
+ }>
70
+ {!hideOrders && (
71
+ <HeaderTitle text={t('MY_ORDERS', 'My Orders')} />
72
+ )}
73
+ {!allEmpty && (
74
+ <ScrollView
75
+ horizontal
76
+ style={{ ...styles.container, borderBottomWidth: 1 }}
77
+ contentContainerStyle={{ paddingHorizontal: !!businessesSearchList ? 0 : 40 }}
78
+ showsHorizontalScrollIndicator={false}
79
+ scrollEventThrottle={16}
80
+ >
81
+ {MyOrdersMenu.filter(option => !hideOrders || option.key !== 'orders').map(option => (
82
+ <Tab
83
+ key={option.key}
84
+ onPress={() => setSelectedOption(option.key)}
85
+ style={
86
+ {
87
+ borderBottomColor:
88
+ selectedOption === option.key
89
+ ? theme.colors.textNormal
90
+ : theme.colors.border,
91
+ }
92
+ }
93
+ >
94
+ <OText>{option?.value}</OText>
95
+ </Tab>
96
+ ))}
97
+ </ScrollView>
98
+ )}
99
+ {selectedOption === 'orders' && (
100
+ <>
101
+ <View style={{ paddingLeft: 40, paddingRight: 40 }}>
102
+ <OrdersOption
103
+ {...props}
104
+ activeOrders
105
+ ordersLength={ordersLength}
106
+ setOrdersLength={setOrdersLength}
107
+ setRefreshOrders={setRefreshOrders}
108
+ refreshOrders={refreshOrders}
109
+ />
110
+ </View>
111
+ <View style={{ paddingLeft: 40, paddingRight: 40 }}>
112
+ <OrdersOption
113
+ {...props}
114
+ ordersLength={ordersLength}
115
+ setOrdersLength={setOrdersLength}
116
+ setRefreshOrders={setRefreshOrders}
117
+ refreshOrders={refreshOrders}
118
+ />
119
+ </View>
120
+ </>
121
+ )}
122
+ {notOrderOptions.includes(selectedOption) && (
38
123
  <OrdersOption
39
124
  {...props}
125
+ titleContent={t('PREVIOUSLY_ORDERED', 'Previously ordered')}
126
+ hideOrders
127
+ horizontal
128
+ isBusiness={selectedOption === 'business'}
129
+ isProducts={selectedOption === 'products'}
40
130
  activeOrders
41
- ordersLength={ordersLength}
42
- setOrdersLength={setOrdersLength}
43
- loadMoreStatus={loadMore}
44
- setLoadMoreStatus={setLoadMore}
45
- />
46
- </View>
47
- <View style={{ paddingLeft: 40, paddingRight: 40 }}>
48
- <OrdersOption
49
- {...props}
131
+ pastOrders
132
+ preOrders
133
+ businessesSearchList={businessesSearchList}
134
+ setIsEmptyBusinesses={setIsEmptyBusinesses}
135
+ businessOrderIds={businessOrderIds}
136
+ setBusinessOrderIds={setBusinessOrderIds}
50
137
  ordersLength={ordersLength}
51
138
  setOrdersLength={setOrdersLength}
52
139
  />
53
- </View>
54
- </ScrollView>
140
+ )}
141
+ </Container>
142
+
55
143
  )
56
144
  }
@@ -3,4 +3,11 @@ import styled, { css } from 'styled-components/native'
3
3
  export const Wrapper = styled.View`
4
4
  flex: 1;
5
5
  background-color: ${(props: any) => props.theme.colors.white};
6
- `
6
+ `
7
+
8
+ export const Tab = styled.TouchableOpacity`
9
+ padding-horizontal: 10px;
10
+ padding-vertical: 10px;
11
+ justify-content: center;
12
+ border-bottom-width: 1px;
13
+ `
@@ -0,0 +1,167 @@
1
+ import React from 'react'
2
+ import { useTheme } from 'styled-components/native'
3
+ import { ScrollView, StyleSheet, View } from 'react-native'
4
+ import { useLanguage, useUtils } from 'ordering-components/native'
5
+ import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'
6
+ import { OText, OButton } from '../shared'
7
+
8
+ export const OrderHistory = (props: any) => {
9
+ const {
10
+ order,
11
+ messages,
12
+ enableReview,
13
+ onClose,
14
+ handleTriggerReview
15
+ } = props
16
+
17
+ const [, t] = useLanguage()
18
+ const [{ parseDate }] = useUtils()
19
+ const theme = useTheme()
20
+
21
+ const styles = StyleSheet.create({
22
+ historyItem: {
23
+ display: 'flex',
24
+ alignItems: 'center',
25
+ flexDirection: 'row',
26
+ borderBottomWidth: 1,
27
+ borderColor: theme.colors.border
28
+ },
29
+ detailWrapper: {
30
+ marginLeft: 20,
31
+ paddingHorizontal: 13,
32
+ paddingVertical: 16
33
+ },
34
+ container: {
35
+ paddingHorizontal: 40,
36
+ paddingVertical: 15
37
+ }
38
+ });
39
+
40
+ const ORDER_STATUS: any = {
41
+ 0: 'ORDER_STATUS_PENDING',
42
+ 1: 'ORDERS_COMPLETED',
43
+ 2: 'ORDER_REJECTED',
44
+ 3: 'ORDER_STATUS_IN_BUSINESS',
45
+ 4: 'ORDER_READY',
46
+ 5: 'ORDER_REJECTED_RESTAURANT',
47
+ 6: 'ORDER_STATUS_CANCELLEDBYDRIVER',
48
+ 7: 'ORDER_STATUS_ACCEPTEDBYRESTAURANT',
49
+ 8: 'ORDER_CONFIRMED_ACCEPTED_BY_DRIVER',
50
+ 9: 'ORDER_PICKUP_COMPLETED_BY_DRIVER',
51
+ 10: 'ORDER_PICKUP_FAILED_BY_DRIVER',
52
+ 11: 'ORDER_DELIVERY_COMPLETED_BY_DRIVER',
53
+ 12: 'ORDER_DELIVERY_FAILED_BY_DRIVER',
54
+ 13: 'PREORDER',
55
+ 14: 'ORDER_NOT_READY',
56
+ 15: 'ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER',
57
+ 16: 'ORDER_STATUS_CANCELLED_BY_CUSTOMER',
58
+ 17: 'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
59
+ 18: 'ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS',
60
+ 19: 'ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER',
61
+ 20: 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS',
62
+ 21: 'ORDER_CUSTOMER_ARRIVED_BUSINESS',
63
+ 22: 'ORDER_LOOKING_FOR_DRIVER',
64
+ 23: 'ORDER_DRIVER_ON_WAY'
65
+ }
66
+
67
+ const getLogisticTagStatus = (status: any) => {
68
+ switch (status) {
69
+ case 0:
70
+ return t('PENDING', 'Pending')
71
+ case 1:
72
+ return t('IN_PROGRESS', 'In Progress')
73
+ case 2:
74
+ return t('IN_QUEUE', 'In Queue')
75
+ case 3:
76
+ return t('EXPIRED', 'Logistic expired')
77
+ case 4:
78
+ return t('RESOLVED', 'Resolved')
79
+ default:
80
+ return status
81
+ }
82
+ }
83
+
84
+ const handleReview = () => {
85
+ if (enableReview) handleTriggerReview()
86
+ else onClose()
87
+ }
88
+
89
+ return (
90
+ <ScrollView contentContainerStyle={styles.container}>
91
+ <OText size={20} style={{ alignSelf: 'center', textAlign: 'center' }} mBottom={10}>
92
+ {t('DETAILS_OF_ORDER', 'Details of Order_NUMBER_').replace('_NUMBER_', ` # ${order?.id}`)}
93
+ </OText>
94
+ {!messages?.loading && order && (
95
+ <View style={styles.historyItem}>
96
+ <MaterialCommunityIcons
97
+ name="checkbox-marked-circle"
98
+ size={20}
99
+ color={theme.colors.primary}
100
+ />
101
+ <View style={styles.detailWrapper}>
102
+ <OText
103
+ size={14}
104
+ weight='bold'
105
+ numberOfLines={1}
106
+ ellipsizeMode='tail'
107
+ >
108
+ {t('ORDER_PLACED', 'Order placed')} {' '}
109
+ {t('VIA', 'Via')}{' '}
110
+ {order.app_id ? t(order.app_id.toUpperCase(), order.app_id) : t('OTHER', 'Other')}
111
+ </OText>
112
+ <OText size={12}>{parseDate(order?.created_at, { outputFormat: 'MMM DD, hh:mm A' })}</OText>
113
+ </View>
114
+ </View>
115
+ )}
116
+ {messages && messages?.messages.map((message: any, i: number) => message.type === 1 && (
117
+ <View
118
+ style={styles.historyItem}
119
+ key={i}
120
+ >
121
+ <MaterialCommunityIcons
122
+ name="checkbox-marked-circle"
123
+ size={20}
124
+ color={theme.colors.primary}
125
+ />
126
+ <View style={styles.detailWrapper}>
127
+ {message.change?.attribute !== 'driver_id' ? (
128
+ <OText
129
+ size={14}
130
+ weight='bold'
131
+ numberOfLines={1}
132
+ ellipsizeMode='tail'
133
+ >
134
+ {message.change?.attribute === 'logistic_status'
135
+ ? getLogisticTagStatus(parseInt(message.change.new, 10))
136
+ : t(ORDER_STATUS[parseInt(message.change.new, 10)])
137
+ }
138
+ </OText>
139
+ ) : (
140
+ <OText
141
+ size={14}
142
+ weight='bold'
143
+ numberOfLines={1}
144
+ ellipsizeMode='tail'
145
+ >
146
+ {message.change.new
147
+ ? (`${message.driver?.name} ${!!message.driver?.lastname ? message.driver.lastname : ''} ${t('WAS_ASSIGNED_AS_DRIVER', 'Was assigned as driver')}`)
148
+ : t('DRIVER_UNASSIGNED', 'Driver unassigned')}
149
+ </OText>
150
+ )}
151
+ <OText size={12}>{parseDate(message?.created_at, { outputFormat: 'MMM DD, hh:mm A' })}</OText>
152
+ </View>
153
+ </View>
154
+ ))}
155
+ <OButton
156
+ text={enableReview ? t('REVIEW_ORDER', 'Review order') : t('CONTINUE', 'Continue')}
157
+ textStyle={{ fontSize: 14, color: theme.colors.white }}
158
+ imgRightSrc={theme.images.general.arrow_right}
159
+ imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
160
+ borderColor='transparent'
161
+ bgColor={theme.colors.primary}
162
+ style={{ borderRadius: 7.6, borderWidth: 1, height: 44, shadowOpacity: 0, marginBottom: 30, marginTop: 20 }}
163
+ onClick={() => handleReview()}
164
+ />
165
+ </ScrollView>
166
+ )
167
+ }
@@ -42,7 +42,8 @@ import { OSRow } from '../OrderSummary/styles';
42
42
  import AntIcon from 'react-native-vector-icons/AntDesign'
43
43
  import { TaxInformation } from '../TaxInformation';
44
44
  import { Placeholder, PlaceholderLine } from 'rn-placeholder';
45
-
45
+ import NavBar from '../NavBar'
46
+ import { OrderHistory } from './OrderHistory';
46
47
  export const OrderDetailsUI = (props: OrderDetailsParams) => {
47
48
  const {
48
49
  navigation,
@@ -82,8 +83,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
82
83
  justifyContent: 'flex-start',
83
84
  paddingLeft: 0,
84
85
  height: 30,
85
- width: 40,
86
+ width: 30,
87
+ marginTop: Platform.OS === 'ios' ? 0 : 30
86
88
  },
89
+ linkWrapper: {
90
+ display: 'flex',
91
+ alignItems: 'center',
92
+ flexDirection: 'row'
93
+ }
87
94
  });
88
95
 
89
96
  const [, t] = useLanguage();
@@ -92,8 +99,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
92
99
  const [{ carts }] = useOrder()
93
100
 
94
101
  const [isReviewed, setIsReviewed] = useState(false)
102
+ const [isOrderHistory, setIsOrderHistory] = useState(false)
95
103
  const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, tax: null, type: '' })
96
104
  const { order, businessData } = props.order;
105
+ const mapValidStatuses = [9, 19, 23]
97
106
 
98
107
  const walletName: any = {
99
108
  cash: {
@@ -331,7 +340,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
331
340
  };
332
341
 
333
342
  const getIncludedTaxes = () => {
334
- if (order?.taxes?.length === 0) {
343
+ if (order?.taxes?.length === 0 || !order?.taxes) {
335
344
  return order.tax_type === 1 ? order?.summary?.tax ?? 0 : 0
336
345
  } else {
337
346
  return order?.taxes.reduce((taxIncluded: number, tax: any) => {
@@ -362,18 +371,34 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
362
371
  )
363
372
  }
364
373
 
374
+ const handleTriggerReview = () => {
375
+ setIsOrderHistory(false);
376
+ (
377
+ parseInt(order?.status) === 1 ||
378
+ parseInt(order?.status) === 11 ||
379
+ parseInt(order?.status) === 15
380
+ ) && !order.review && !isReviewed && handleClickOrderReview(order)
381
+ }
365
382
 
366
383
  useEffect(() => {
384
+ const _businessId = 'businessId:' + businessData?.id
367
385
  if (reorderState?.error) {
368
- const _businessId = 'businessId:' + businessData?.id
369
- const _uuid = carts[_businessId]?.uuid
370
- if (_uuid) {
371
- _setStoreData('remove-cartId', JSON.stringify(_uuid))
386
+ if (businessData?.id) {
387
+ _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
372
388
  navigation.navigate('Business', { store: businessData?.slug })
373
389
  }
374
390
  }
375
- if (!reorderState?.error && reorderState?.result?.uuid) {
376
- onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: reorderState?.result.uuid })
391
+ if (!reorderState?.error && reorderState.loading === false && businessData?.id) {
392
+ const products = carts?.[_businessId]?.products
393
+ const available = products?.every((product: any) => product.valid === true)
394
+
395
+ if (available && reorderState?.result?.uuid && (products?.length === order?.products.length)) {
396
+ onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: reorderState?.result.uuid })
397
+ } else {
398
+ _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
399
+ products?.length !== order?.products.length && _setStoreData('already-removed', JSON.stringify('removed'))
400
+ navigation.navigate('Business', { store: businessData?.slug })
401
+ }
377
402
  }
378
403
  }, [reorderState])
379
404
 
@@ -405,10 +430,19 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
405
430
  'https://res.cloudinary.com/demo/image/upload/c_thumb,g_face,r_max/d_avatar.png/non_existing_id.png',
406
431
  },
407
432
  ];
433
+ const driverLocationString = typeof order?.driver?.location?.location === 'string' && order?.driver?.location?.location?.split(',').map((l: string) => l.replace(/[^-.0-9]/g, ''))
434
+ const parsedLocations = locations.map(location => typeof location?.location === 'string' ? {
435
+ ...location,
436
+ lat: parseFloat(location?.location?.split(',')[0].replace(/[^-.0-9]/g, '')),
437
+ lng: parseFloat(location?.location?.split(',')[1].replace(/[^-.0-9]/g, ''))
438
+ } : location)
408
439
 
409
440
  useEffect(() => {
410
441
  if (driverLocation) {
411
- locations[0] = driverLocation;
442
+ parsedLocations[0] = {
443
+ ...locations[0],
444
+ ...driverLocation
445
+ }
412
446
  }
413
447
  }, [driverLocation]);
414
448
 
@@ -469,28 +503,25 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
469
503
  {order && Object.keys(order).length > 0 && (
470
504
  <>
471
505
  <Header>
472
- <OButton
473
- imgLeftSrc={theme.images.general.arrow_left}
474
- imgRightSrc={null}
475
- style={styles.btnBackArrow}
476
- onClick={() => handleArrowBack()}
477
- imgLeftStyle={{ tintColor: theme.colors.disabled }}
506
+ <NavBar
507
+ title={`${t('ORDER', 'Order')} #${order?.id}`}
508
+ titleAlign={'center'}
509
+ onActionLeft={handleArrowBack}
510
+ showCall={false}
511
+ btnStyle={{ paddingLeft: 0 }}
512
+ style={{ marginTop: Platform.OS === 'ios' ? 0 : 20 }}
513
+ titleWrapStyle={{ paddingHorizontal: 0 }}
514
+ titleStyle={{ marginRight: 0, marginLeft: 0 }}
515
+ subTitle={<OText size={12} lineHeight={18} color={theme.colors.textNormal}>
516
+ {order?.delivery_datetime_utc
517
+ ? parseDate(order?.delivery_datetime_utc)
518
+ : parseDate(order?.delivery_datetime, { utc: false })}
519
+ </OText>}
478
520
  />
479
521
  <OrderInfo>
480
522
  <OrderData>
481
- <OText
482
- size={20}
483
- lineHeight={30}
484
- weight={'600'}
485
- color={theme.colors.textNormal}>
486
- {t('ORDER', 'Order')} #{order?.id}
487
- </OText>
488
- <OText size={12} lineHeight={18} color={theme.colors.textNormal}>
489
- {order?.delivery_datetime_utc
490
- ? parseDate(order?.delivery_datetime_utc)
491
- : parseDate(order?.delivery_datetime, { utc: false })}
492
- </OText>
493
- {
523
+ <View style={styles.linkWrapper}>
524
+ {
494
525
  (
495
526
  parseInt(order?.status) === 1 ||
496
527
  parseInt(order?.status) === 11 ||
@@ -498,20 +529,36 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
498
529
  ) && !order.review && !isReviewed && (
499
530
  <TouchableOpacity
500
531
  activeOpacity={0.7}
501
- style={{ marginTop: 6 }}
532
+ style={{ marginTop: 6, marginRight: 10 }}
502
533
  onPress={() => handleClickOrderReview(order)}
503
-
504
534
  >
505
535
  <OText
506
536
  size={10}
507
537
  lineHeight={15}
508
- color={theme.colors.textSecondary}
538
+ color={theme.colors.primary}
509
539
  style={{ textDecorationLine: 'underline' }}
510
540
  >
511
541
  {t('REVIEW_YOUR_ORDER', 'Review your order')}
512
542
  </OText>
513
543
  </TouchableOpacity>
514
544
  )}
545
+ <TouchableOpacity
546
+ activeOpacity={0.7}
547
+ style={{ marginTop: 6 }}
548
+ onPress={() => setIsOrderHistory(true)}
549
+
550
+ >
551
+ <OText
552
+ size={10}
553
+ lineHeight={15}
554
+ color={theme.colors.primary}
555
+ style={{ textDecorationLine: 'underline', textTransform: 'capitalize' }}
556
+ >
557
+ {t('VIEW_DETAILS', 'View Details')}
558
+ </OText>
559
+ </TouchableOpacity>
560
+ </View>
561
+
515
562
  <StaturBar>
516
563
  <LinearGradient
517
564
  start={{ x: 0.0, y: 0.0 }}
@@ -651,13 +698,15 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
651
698
  mBottom={2}>
652
699
  {order?.customer?.address}
653
700
  </OText>
654
- <OText
655
- size={12}
656
- lineHeight={18}
657
- color={theme.colors.textNormal}
658
- mBottom={2}>
659
- {order?.customer?.cellphone}
660
- </OText>
701
+ {(!!order?.customer?.cellphone) && (
702
+ <OText
703
+ size={12}
704
+ lineHeight={18}
705
+ color={theme.colors.textNormal}
706
+ mBottom={2}>
707
+ {`${!!order?.customer?.country_phone_code ? '+' + order?.customer?.country_phone_code : ''} ${order?.customer?.cellphone}`}
708
+ </OText>
709
+ )}
661
710
  </InfoBlock>
662
711
  </Customer>
663
712
  {order?.delivery_option !== undefined && order?.delivery_type === 1 && (
@@ -670,7 +719,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
670
719
  </OText>
671
720
  </View>
672
721
  )}
673
- {order?.comment && (
722
+ {!!order?.comment && (
674
723
  <View style={{ marginTop: 15 }}>
675
724
  <OText size={16} style={{ textAlign: 'left' }} color={theme.colors.textNormal}>
676
725
  {t('COMMENT', 'Comment')}
@@ -680,11 +729,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
680
729
  )}
681
730
  {order?.driver && (
682
731
  <>
683
- {order?.driver?.location && parseInt(order?.status) === 9 && (
732
+ {order?.driver?.location && mapValidStatuses.includes(parseInt(order?.status)) && (
684
733
  <Map>
685
- <GoogleMap
686
- location={order?.driver?.location}
687
- locations={locations}
734
+ <GoogleMap
735
+ location={typeof order?.driver?.location?.location === 'string'
736
+ ? {
737
+ lat: parseFloat(driverLocationString[0]),
738
+ lng: parseFloat(driverLocationString[1]),
739
+ } : driverLocation ?? order?.driver?.location
740
+ }
741
+ locations={parsedLocations}
688
742
  readOnly
689
743
  />
690
744
  </Map>
@@ -898,7 +952,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
898
952
  <OSRow>
899
953
  <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal} numberOfLines={1}>
900
954
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
901
- ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%){' '}
955
+ ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)}${fee.percentage > 0 ? ' + ' : ''}`}{fee.percentage > 0 && `${fee.percentage}%`}){' '}
902
956
  </OText>
903
957
  <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })}>
904
958
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
@@ -1010,7 +1064,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
1010
1064
  )}
1011
1065
  </View>
1012
1066
  <OText>
1013
- -{parsePrice(event.amount)}
1067
+ -{parsePrice(event.amount, { isTruncable: true })}
1014
1068
  </OText>
1015
1069
  </View>
1016
1070
  ))}
@@ -1032,6 +1086,23 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
1032
1086
  products={order?.products}
1033
1087
  />
1034
1088
  </OModal>
1089
+ <OModal
1090
+ open={isOrderHistory}
1091
+ onClose={() => setIsOrderHistory(false)}
1092
+ entireModal
1093
+ >
1094
+ <OrderHistory
1095
+ order={order}
1096
+ messages={messages}
1097
+ enableReview={(
1098
+ parseInt(order?.status) === 1 ||
1099
+ parseInt(order?.status) === 11 ||
1100
+ parseInt(order?.status) === 15
1101
+ ) && !order.review && !isReviewed}
1102
+ onClose={() => setIsOrderHistory(false)}
1103
+ handleTriggerReview={handleTriggerReview}
1104
+ />
1105
+ </OModal>
1035
1106
  </OrderDetailsContainer>
1036
1107
  );
1037
1108
  };
@@ -5,7 +5,6 @@ export const OrderDetailsContainer = styled.ScrollView`
5
5
  `
6
6
 
7
7
  export const NavBack = styled.TouchableOpacity`
8
-
9
8
  `
10
9
 
11
10
 
@@ -127,4 +126,4 @@ export const Divider = styled.View`
127
126
  `
128
127
  export const OrderAction = styled.View`
129
128
  flex-direction: row;
130
- `
129
+ `