ordering-ui-react-native 0.15.35 → 0.15.37-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 (187) hide show
  1. package/package.json +4 -2
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessController/index.tsx +8 -2
  4. package/src/components/BusinessTypeFilter/index.tsx +4 -1
  5. package/src/components/BusinessesListing/index.tsx +1 -1
  6. package/src/components/Checkout/index.tsx +23 -3
  7. package/src/components/DriverTips/index.tsx +11 -6
  8. package/src/components/LanguageSelector/index.tsx +7 -2
  9. package/src/components/LoginForm/index.tsx +3 -1
  10. package/src/components/OrderDetails/index.tsx +2 -2
  11. package/src/components/PaymentOptions/index.tsx +9 -16
  12. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  13. package/src/components/SignupForm/index.tsx +3 -1
  14. package/src/components/SingleProductCard/index.tsx +16 -4
  15. package/src/components/StripeElementsForm/index.tsx +27 -48
  16. package/src/components/StripeMethodForm/index.tsx +1 -2
  17. package/src/components/UpsellingProducts/index.tsx +1 -1
  18. package/src/components/UserProfileForm/index.tsx +63 -6
  19. package/src/components/UserProfileForm/styles.tsx +8 -0
  20. package/src/components/VerifyPhone/styles.tsx +1 -2
  21. package/src/components/shared/OModal.tsx +1 -1
  22. package/src/config.json +0 -2
  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/BusinessProductsList.tsx +1 -0
  27. package/src/pages/BusinessesListing.tsx +1 -1
  28. package/src/pages/Checkout.tsx +1 -1
  29. package/src/pages/MultiCheckout.tsx +31 -0
  30. package/src/pages/MultiOrdersDetails.tsx +27 -0
  31. package/src/pages/Sessions.tsx +22 -0
  32. package/src/types/index.tsx +5 -11
  33. package/src/utils/index.tsx +68 -1
  34. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  35. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  36. package/themes/business/src/components/Chat/index.tsx +38 -86
  37. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  38. package/themes/business/src/components/Home/index.tsx +128 -55
  39. package/themes/business/src/components/Home/styles.tsx +8 -1
  40. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  41. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  42. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  43. package/themes/business/src/components/NewOrderNotification/index.tsx +79 -105
  44. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  45. package/themes/business/src/components/OrderDetails/Delivery.tsx +32 -15
  46. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +157 -89
  47. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  48. package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
  49. package/themes/business/src/components/OrdersListManager/index.tsx +52 -49
  50. package/themes/business/src/components/OrdersOption/index.tsx +57 -50
  51. package/themes/business/src/components/PreviousOrders/index.tsx +50 -14
  52. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  53. package/themes/business/src/components/shared/OModal.tsx +1 -1
  54. package/themes/business/src/types/index.tsx +5 -1
  55. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  56. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  57. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  58. package/themes/kiosk/src/components/Cart/index.tsx +99 -25
  59. package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
  60. package/themes/kiosk/src/components/Checkout/index.tsx +34 -22
  61. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  62. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  63. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  64. package/themes/kiosk/src/components/OrderDetails/index.tsx +165 -65
  65. package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
  66. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
  67. package/themes/kiosk/src/components/PaymentOptions/index.tsx +1 -1
  68. package/themes/kiosk/src/components/ProductForm/index.tsx +2 -2
  69. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  70. package/themes/kiosk/src/types/index.d.ts +2 -0
  71. package/themes/original/index.tsx +190 -1
  72. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  73. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  74. package/themes/original/src/components/AddressForm/index.tsx +15 -10
  75. package/themes/original/src/components/AddressList/index.tsx +56 -18
  76. package/themes/original/src/components/AppleLogin/index.tsx +117 -78
  77. package/themes/original/src/components/BusinessBasicInformation/index.tsx +96 -45
  78. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
  79. package/themes/original/src/components/BusinessController/index.tsx +56 -16
  80. package/themes/original/src/components/BusinessController/styles.tsx +27 -0
  81. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  82. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  83. package/themes/original/src/components/BusinessItemAccordion/index.tsx +4 -3
  84. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  85. package/themes/original/src/components/BusinessListingSearch/index.tsx +200 -58
  86. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  87. package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
  88. package/themes/original/src/components/BusinessPreorder/index.tsx +142 -122
  89. package/themes/original/src/components/BusinessProductsCategories/index.tsx +9 -7
  90. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  91. package/themes/original/src/components/BusinessProductsList/index.tsx +139 -36
  92. package/themes/original/src/components/BusinessProductsList/styles.tsx +29 -2
  93. package/themes/original/src/components/BusinessProductsListing/index.tsx +125 -21
  94. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
  95. package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
  96. package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
  97. package/themes/original/src/components/BusinessesListing/index.tsx +143 -81
  98. package/themes/original/src/components/BusinessesListing/styles.tsx +11 -3
  99. package/themes/original/src/components/Cart/index.tsx +60 -43
  100. package/themes/original/src/components/CartContent/index.tsx +2 -2
  101. package/themes/original/src/components/Checkout/index.tsx +59 -48
  102. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  103. package/themes/original/src/components/Favorite/index.tsx +91 -0
  104. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  105. package/themes/original/src/components/FavoriteList/index.tsx +287 -0
  106. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  107. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  108. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  109. package/themes/original/src/components/GoogleMap/index.tsx +1 -0
  110. package/themes/original/src/components/Help/index.tsx +21 -4
  111. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  112. package/themes/original/src/components/Home/index.tsx +1 -1
  113. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  114. package/themes/original/src/components/LoginForm/Otp/index.tsx +90 -0
  115. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  116. package/themes/original/src/components/LoginForm/index.tsx +394 -155
  117. package/themes/original/src/components/LoginForm/styles.tsx +7 -4
  118. package/themes/original/src/components/LogoutButton/index.tsx +7 -1
  119. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  120. package/themes/original/src/components/Messages/index.tsx +6 -1
  121. package/themes/original/src/components/Messages/styles.tsx +1 -3
  122. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  123. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  124. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  125. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  126. package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
  127. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  128. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  129. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  130. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  131. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  132. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  133. package/themes/original/src/components/OrderDetails/index.tsx +56 -33
  134. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  135. package/themes/original/src/components/OrderProgress/index.tsx +3 -3
  136. package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
  137. package/themes/original/src/components/OrderSummary/index.tsx +3 -3
  138. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  139. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  140. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  141. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  142. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  143. package/themes/original/src/components/OrdersOption/index.tsx +133 -41
  144. package/themes/original/src/components/OrdersOption/styles.tsx +4 -7
  145. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  146. package/themes/original/src/components/PaymentOptionWallet/index.tsx +22 -24
  147. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  148. package/themes/original/src/components/PaymentOptions/index.tsx +9 -21
  149. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  150. package/themes/original/src/components/PreviousOrders/index.tsx +18 -145
  151. package/themes/original/src/components/ProductForm/index.tsx +76 -61
  152. package/themes/original/src/components/ProductForm/styles.tsx +0 -1
  153. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  154. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  155. package/themes/original/src/components/Promotions/index.tsx +250 -0
  156. package/themes/original/src/components/Promotions/styles.tsx +60 -0
  157. package/themes/original/src/components/SearchBar/index.tsx +10 -4
  158. package/themes/original/src/components/Sessions/index.tsx +160 -0
  159. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  160. package/themes/original/src/components/SignupForm/index.tsx +9 -4
  161. package/themes/original/src/components/SingleOrderCard/index.tsx +282 -0
  162. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  163. package/themes/original/src/components/SingleProductCard/index.tsx +95 -32
  164. package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
  165. package/themes/original/src/components/StripeElementsForm/index.tsx +10 -2
  166. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  167. package/themes/original/src/components/TaxInformation/index.tsx +10 -4
  168. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  169. package/themes/original/src/components/UserDetails/index.tsx +5 -96
  170. package/themes/original/src/components/UserFormDetails/index.tsx +34 -24
  171. package/themes/original/src/components/UserProfile/index.tsx +62 -8
  172. package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
  173. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  174. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  175. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  176. package/themes/original/src/components/Wallets/index.tsx +76 -9
  177. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  178. package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
  179. package/themes/original/src/components/shared/OModal.tsx +4 -2
  180. package/themes/original/src/components/shared/index.tsx +2 -0
  181. package/themes/original/src/config/constants.tsx +6 -6
  182. package/themes/original/src/types/index.tsx +132 -9
  183. package/themes/original/src/utils/index.tsx +28 -2
  184. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  185. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
  186. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
  187. 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
+ `
@@ -1,10 +1,12 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import { View, StyleSheet, BackHandler, Platform, Linking } from 'react-native';
3
3
  import LinearGradient from 'react-native-linear-gradient';
4
+ import { _setStoreData } from '../../providers/StoreUtil';
4
5
  import {
5
6
  useLanguage,
6
7
  OrderDetails as OrderDetailsConTableoller,
7
8
  useUtils,
9
+ useOrder,
8
10
  useConfig
9
11
  } from 'ordering-components/native';
10
12
  import { useTheme } from 'styled-components/native';
@@ -40,7 +42,7 @@ import { OSRow } from '../OrderSummary/styles';
40
42
  import AntIcon from 'react-native-vector-icons/AntDesign'
41
43
  import { TaxInformation } from '../TaxInformation';
42
44
  import { Placeholder, PlaceholderLine } from 'rn-placeholder';
43
-
45
+ import NavBar from '../NavBar'
44
46
  export const OrderDetailsUI = (props: OrderDetailsParams) => {
45
47
  const {
46
48
  navigation,
@@ -80,17 +82,20 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
80
82
  justifyContent: 'flex-start',
81
83
  paddingLeft: 0,
82
84
  height: 30,
83
- width: 40,
85
+ width: 30,
86
+ marginTop: Platform.OS === 'ios' ? 0 : 30
84
87
  },
85
88
  });
86
89
 
87
90
  const [, t] = useLanguage();
88
91
  const [{ parsePrice, parseNumber, parseDate }] = useUtils();
89
92
  const [{ configs }] = useConfig();
93
+ const [{ carts }] = useOrder()
94
+
90
95
  const [isReviewed, setIsReviewed] = useState(false)
91
96
  const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, tax: null, type: '' })
92
-
93
97
  const { order, businessData } = props.order;
98
+ const mapValidStatuses = [9, 19, 23]
94
99
 
95
100
  const walletName: any = {
96
101
  cash: {
@@ -328,7 +333,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
328
333
  };
329
334
 
330
335
  const getIncludedTaxes = () => {
331
- if (order?.taxes?.length === 0) {
336
+ if (order?.taxes?.length === 0 || !order?.taxes) {
332
337
  return order.tax_type === 1 ? order?.summary?.tax ?? 0 : 0
333
338
  } else {
334
339
  return order?.taxes.reduce((taxIncluded: number, tax: any) => {
@@ -361,11 +366,24 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
361
366
 
362
367
 
363
368
  useEffect(() => {
369
+ const _businessId = 'businessId:' + businessData?.id
364
370
  if (reorderState?.error) {
365
- navigation.navigate('Business', { store: businessData?.slug })
371
+ if (businessData?.id) {
372
+ _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
373
+ navigation.navigate('Business', { store: businessData?.slug })
374
+ }
366
375
  }
367
- if (!reorderState?.error && reorderState?.result?.uuid) {
368
- onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: reorderState?.result.uuid })
376
+ if (!reorderState?.error && reorderState.loading === false && businessData?.id) {
377
+ const products = carts?.[_businessId]?.products
378
+ const available = products.every((product: any) => product.valid === true)
379
+
380
+ if (available && reorderState?.result?.uuid && (products?.length === order?.products.length)) {
381
+ onNavigationRedirect && onNavigationRedirect('CheckoutNavigator', { cartUuid: reorderState?.result.uuid })
382
+ } else {
383
+ _setStoreData('adjust-cart-products', JSON.stringify(_businessId))
384
+ products?.length !== order?.products.length && _setStoreData('already-removed', JSON.stringify('removed'))
385
+ navigation.navigate('Business', { store: businessData?.slug })
386
+ }
369
387
  }
370
388
  }, [reorderState])
371
389
 
@@ -397,6 +415,12 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
397
415
  'https://res.cloudinary.com/demo/image/upload/c_thumb,g_face,r_max/d_avatar.png/non_existing_id.png',
398
416
  },
399
417
  ];
418
+ const driverLocationString = typeof order?.driver?.location?.location === 'string' && order?.driver?.location?.location?.split(',').map((l: string) => l.replace(/[^-.0-9]/g, ''))
419
+ const parsedLocations = locations.map(location => typeof location?.location === 'string' ? {
420
+ ...location,
421
+ lat: parseFloat(location?.location?.split(',')[0].replace(/[^-.0-9]/g, '')),
422
+ lng: parseFloat(location?.location?.split(',')[1].replace(/[^-.0-9]/g, ''))
423
+ } : location)
400
424
 
401
425
  useEffect(() => {
402
426
  if (driverLocation) {
@@ -461,27 +485,23 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
461
485
  {order && Object.keys(order).length > 0 && (
462
486
  <>
463
487
  <Header>
464
- <OButton
465
- imgLeftSrc={theme.images.general.arrow_left}
466
- imgRightSrc={null}
467
- style={styles.btnBackArrow}
468
- onClick={() => handleArrowBack()}
469
- imgLeftStyle={{ tintColor: theme.colors.disabled }}
488
+ <NavBar
489
+ title={`${t('ORDER', 'Order')} #${order?.id}`}
490
+ titleAlign={'center'}
491
+ onActionLeft={handleArrowBack}
492
+ showCall={false}
493
+ btnStyle={{ paddingLeft: 0 }}
494
+ style={{ marginTop: Platform.OS === 'ios' ? 0 : 20 }}
495
+ titleWrapStyle={{ paddingHorizontal: 0 }}
496
+ titleStyle={{ marginRight: 0, marginLeft: 0 }}
497
+ subTitle={<OText size={12} lineHeight={18} color={theme.colors.textNormal}>
498
+ {order?.delivery_datetime_utc
499
+ ? parseDate(order?.delivery_datetime_utc)
500
+ : parseDate(order?.delivery_datetime, { utc: false })}
501
+ </OText>}
470
502
  />
471
503
  <OrderInfo>
472
504
  <OrderData>
473
- <OText
474
- size={20}
475
- lineHeight={30}
476
- weight={'600'}
477
- color={theme.colors.textNormal}>
478
- {t('ORDER', 'Order')} #{order?.id}
479
- </OText>
480
- <OText size={12} lineHeight={18} color={theme.colors.textNormal}>
481
- {order?.delivery_datetime_utc
482
- ? parseDate(order?.delivery_datetime_utc)
483
- : parseDate(order?.delivery_datetime, { utc: false })}
484
- </OText>
485
505
  {
486
506
  (
487
507
  parseInt(order?.status) === 1 ||
@@ -662,7 +682,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
662
682
  </OText>
663
683
  </View>
664
684
  )}
665
- {order?.comment && (
685
+ {!!order?.comment && (
666
686
  <View style={{ marginTop: 15 }}>
667
687
  <OText size={16} style={{ textAlign: 'left' }} color={theme.colors.textNormal}>
668
688
  {t('COMMENT', 'Comment')}
@@ -672,11 +692,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
672
692
  )}
673
693
  {order?.driver && (
674
694
  <>
675
- {order?.driver?.location && parseInt(order?.status) === 9 && (
695
+ {order?.driver?.location && mapValidStatuses.includes(parseInt(order?.status)) && (
676
696
  <Map>
677
- <GoogleMap
678
- location={order?.driver?.location}
679
- locations={locations}
697
+ <GoogleMap
698
+ location={typeof order?.driver?.location?.location === 'string'
699
+ ? {
700
+ lat: parseFloat(driverLocationString[0]),
701
+ lng: parseFloat(driverLocationString[1]),
702
+ } : driverLocation ?? order?.driver?.location
703
+ }
704
+ locations={parsedLocations}
680
705
  readOnly
681
706
  />
682
707
  </Map>
@@ -890,7 +915,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
890
915
  <OSRow>
891
916
  <OText size={12} lineHeight={18} weight={'400'} color={theme.colors.textNormal} numberOfLines={1}>
892
917
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
893
- ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%){' '}
918
+ ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)}${fee.percentage > 0 ? ' + ' : ''}`}{fee.percentage > 0 && `${fee.percentage}%`}){' '}
894
919
  </OText>
895
920
  <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })}>
896
921
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
@@ -1017,8 +1042,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
1017
1042
  open={openTaxModal.open}
1018
1043
  onClose={() => setOpenTaxModal({ open: false, data: null, type: '' })}
1019
1044
  entireModal
1020
- title={`${openTaxModal.data?.name ||
1021
- t('INHERIT_FROM_BUSINESS', 'Inherit from business')} ${openTaxModal.data?.rate_type !== 2 ? `(${typeof openTaxModal.data?.rate === 'number' ? `${openTaxModal.data?.rate}%` : `${parsePrice(openTaxModal.data?.fixed ?? 0)} + ${openTaxModal.data?.percentage}%`})` : ''} `}
1022
1045
  >
1023
1046
  <TaxInformation
1024
1047
  type={openTaxModal.type}
@@ -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
+ `
@@ -98,7 +98,7 @@ const OrderProgressUI = (props: any) => {
98
98
  { key: 20, value: t('ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS', theme?.defaultLanguages?.ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS || 'Customer almost arrived to business'), slug: 'ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS', percentage: 90 },
99
99
  { key: 21, value: t('ORDER_CUSTOMER_ARRIVED_BUSINESS', theme?.defaultLanguages?.ORDER_CUSTOMER_ARRIVED_BUSINESS || 'Customer arrived to business'), slug: 'ORDER_CUSTOMER_ARRIVED_BUSINESS', percentage: 95 },
100
100
  { key: 22, value: t('ORDER_LOOKING_FOR_DRIVER', theme?.defaultLanguages?.ORDER_LOOKING_FOR_DRIVER || 'Looking for driver'), slug: 'ORDER_LOOKING_FOR_DRIVER', percentage: 35 },
101
- { key: 23, value: t('ORDER_DRIVER_ON_WAY', theme?.defaultLanguages?.ORDER_DRIVER_ON_WAY || 'Driver on way'), slug: 'ORDER_DRIVER_ON_WAY', percentage: 45 }
101
+ { key: 23, value: t('ORDER_DRIVER_ON_WAY', theme?.defaultLanguages?.ORDER_DRIVER_ON_WAY || 'Driver on way'), slug: 'ORDER_DRIVER_ON_WAY', percentage: 45 }
102
102
  ]
103
103
 
104
104
  const objectStatus = orderStatus.find((o) => o.key === status)
@@ -131,7 +131,7 @@ const OrderProgressUI = (props: any) => {
131
131
 
132
132
  useEffect(() => {
133
133
  if (isFocused) {
134
- loadOrders()
134
+ loadOrders(false, false, false, true)
135
135
  }
136
136
  }, [isFocused])
137
137
 
@@ -188,7 +188,7 @@ const OrderProgressUI = (props: any) => {
188
188
  <ProgressBar style={{ width: getOrderStatus(lastOrder.status)?.percentage ? `${getOrderStatus(lastOrder.status)?.percentage}%` : '0%' }} />
189
189
  </ProgressContentWrapper>
190
190
  <ProgressTextWrapper>
191
- <OText size={12}>{getOrderStatus(lastOrder.status)?.value}</OText>
191
+ <OText size={12} style={{ width: '50%' }}>{getOrderStatus(lastOrder.status)?.value}</OText>
192
192
  <TimeWrapper>
193
193
  <OText size={11}>{t('ESTIMATED_DELIVERY', 'Estimated delivery')}</OText>
194
194
  <OText size={11}>
@@ -20,6 +20,7 @@ export const ProgressTextWrapper = styled.View`
20
20
  flex-direction: row;
21
21
  justify-content: space-between;
22
22
  align-items: center;
23
+ width: 100%;
23
24
  `
24
25
 
25
26
  export const OrderInfoWrapper = styled.View`
@@ -71,7 +71,7 @@ const OrderSummaryUI = (props: any) => {
71
71
  }
72
72
 
73
73
  const getIncludedTaxes = () => {
74
- if (cart?.taxes === null) {
74
+ if (cart?.taxes === null || !cart?.taxes) {
75
75
  return cart.business.tax_type === 1 ? cart?.tax : 0
76
76
  } else {
77
77
  return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
@@ -112,7 +112,7 @@ const OrderSummaryUI = (props: any) => {
112
112
  {cart?.products?.length > 0 && (
113
113
  <>
114
114
  <OSProductList>
115
- {cart?.products.map((product: any) => (
115
+ {cart?.products?.map((product: any) => (
116
116
  <ProductItemAccordion
117
117
  key={product.code}
118
118
  product={product}
@@ -202,7 +202,7 @@ const OrderSummaryUI = (props: any) => {
202
202
  <OSRow>
203
203
  <OText size={12} numberOfLines={1}>
204
204
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
205
- ({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
205
+ ({fee?.fixed > 0 && `${parsePrice(fee?.fixed)}${fee.percentage > 0 ? ' + ' : ''}`}{fee.percentage > 0 && `${fee.percentage}%`}){' '}
206
206
  </OText>
207
207
  <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
208
208
  <AntIcon name='infocirlceo' size={16} color={theme.colors.primary} />
@@ -19,7 +19,8 @@ const OrderTypeSelectorUI = (props: OrderTypeSelectParams) => {
19
19
  typeSelected,
20
20
  defaultValue,
21
21
  configTypes,
22
- orderTypes
22
+ orderTypes,
23
+ setOrderTypeValue
23
24
  } = props
24
25
 
25
26
  const theme = useTheme();
@@ -39,6 +40,7 @@ const OrderTypeSelectorUI = (props: OrderTypeSelectParams) => {
39
40
 
40
41
  const handleChangeOrderTypeCallback = (orderType: number) => {
41
42
  if (!orderState.loading) {
43
+ setOrderTypeValue && setOrderTypeValue(orderType)
42
44
  handleChangeOrderType(orderType)
43
45
  goToBack();
44
46
  }
@@ -51,7 +53,7 @@ const OrderTypeSelectorUI = (props: OrderTypeSelectParams) => {
51
53
  btnStyle={{ paddingLeft: 0 }}
52
54
  paddingTop={0}
53
55
  style={{ paddingBottom: 0 }}
54
- title={t('HOW_WILL_YOUR_ORDER_TYPE', 'How will your order type?')}
56
+ title={t('HOW_WILL_YOU_DELIVERY_TYPE', 'How will your order type?')}
55
57
  titleAlign={'center'}
56
58
  titleStyle={{ fontSize: 14 }}
57
59
  />
@@ -0,0 +1,153 @@
1
+ import React, { useEffect } from 'react'
2
+ import { BusinessList as BusinessListController, useOrder } from 'ordering-components/native'
3
+ import { BusinessController } from '../../BusinessController'
4
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
5
+
6
+ import { ListWrapper } from './styles'
7
+ import {
8
+ View,
9
+ StyleSheet,
10
+ ScrollView,
11
+ Dimensions
12
+ } from 'react-native';
13
+ import { PreviousBusinessOrderedParams } from '../../../types';
14
+
15
+ export const PreviousBusinessOrderedUI = (props: PreviousBusinessOrderedParams) => {
16
+ const {
17
+ navigation,
18
+ businessesList,
19
+ setBusinessLoading,
20
+ businessId,
21
+ onNavigationRedirect,
22
+ isBusinessesSearchList,
23
+ businessLoading
24
+ } = props
25
+
26
+ const [orderState] = useOrder()
27
+ const windowWidth = Dimensions.get('window').width;
28
+
29
+ const onBusinessClick = (business: any) => {
30
+ onNavigationRedirect('Business', { store: business.slug })
31
+ }
32
+ useEffect(() => {
33
+ if (businessesList?.loading && businessesList?.businesses?.length === 0) {
34
+ setBusinessLoading(true)
35
+ } else {
36
+ setBusinessLoading(false)
37
+ }
38
+ }, [businessesList?.loading])
39
+
40
+ const styles = StyleSheet.create({
41
+ container: {
42
+ marginBottom: 0,
43
+ },
44
+ });
45
+
46
+ const BusinessControllerList = ({ style }: any) => {
47
+ return (
48
+ <>
49
+ {businessesList.businesses?.filter((business: any) => businessId?.includes(business?.id))?.map((business: any, i: number) => (
50
+ <BusinessController
51
+ key={`${business.id}_` + i}
52
+ business={business}
53
+ isBusinessOpen={business.open}
54
+ handleCustomClick={() => onBusinessClick(business)}
55
+ orderType={orderState?.options?.type}
56
+ navigation={navigation}
57
+ businessHeader={business?.header}
58
+ businessFeatured={business?.featured}
59
+ businessLogo={business?.logo}
60
+ businessReviews={business?.reviews}
61
+ businessDeliveryPrice={business?.delivery_price}
62
+ businessDeliveryTime={business?.delivery_time}
63
+ businessPickupTime={business?.pickup_time}
64
+ businessDistance={business?.distance}
65
+ style={style}
66
+ />
67
+ ))}
68
+ </>
69
+ )
70
+ }
71
+
72
+ const BusinessSkeletons = () => {
73
+ return (
74
+ <>
75
+ {[...Array(4).keys()].map((item, i) => (
76
+ <Placeholder
77
+ Animation={Fade}
78
+ key={i}
79
+ style={{ marginBottom: 20 }}>
80
+ <View style={{ width: '100%' }}>
81
+ <PlaceholderLine
82
+ height={200}
83
+ style={{ marginBottom: 20, borderRadius: 25 }}
84
+ />
85
+ <View style={{ paddingHorizontal: 10 }}>
86
+ <View
87
+ style={{
88
+ flexDirection: 'row',
89
+ justifyContent: 'space-between',
90
+ }}>
91
+ <PlaceholderLine
92
+ height={25}
93
+ width={40}
94
+ style={{ marginBottom: 10 }}
95
+ />
96
+ <PlaceholderLine
97
+ height={25}
98
+ width={20}
99
+ style={{ marginBottom: 10 }}
100
+ />
101
+ </View>
102
+ <PlaceholderLine
103
+ height={20}
104
+ width={30}
105
+ style={{ marginBottom: 10 }}
106
+ />
107
+ <PlaceholderLine
108
+ height={20}
109
+ width={80}
110
+ style={{ marginBottom: 10 }}
111
+ />
112
+ </View>
113
+ </View>
114
+ </Placeholder>
115
+ ))}
116
+ </>
117
+ )
118
+ }
119
+
120
+ return (
121
+ <ScrollView horizontal={isBusinessesSearchList} style={styles.container} showsVerticalScrollIndicator={false}>
122
+ {isBusinessesSearchList ? (
123
+ <>
124
+ {!businessLoading && (
125
+ <BusinessControllerList
126
+ style={{ width: windowWidth - 80, marginRight: 20 }}
127
+ />
128
+ )}
129
+ </>
130
+ ) : (
131
+ <ListWrapper>
132
+ <BusinessControllerList />
133
+ {businessesList.loading && (
134
+ <BusinessSkeletons />
135
+ )}
136
+ </ListWrapper>
137
+ )}
138
+
139
+ </ScrollView>
140
+ )
141
+ }
142
+
143
+ export const PreviousBusinessOrdered = (props: PreviousBusinessOrderedParams) => {
144
+ const previousBusinessOrderedController = {
145
+ ...props,
146
+ UIComponent: PreviousBusinessOrderedUI,
147
+ paginationSettings: { initialPage: 1, pageSize: 50, controlType: 'infinity' }
148
+ }
149
+
150
+ return (
151
+ <BusinessListController {...previousBusinessOrderedController} />
152
+ )
153
+ }
@@ -0,0 +1,6 @@
1
+ import styled, { css } from 'styled-components/native'
2
+
3
+ export const ListWrapper = styled.View`
4
+ background-color: ${(props: any) => props.theme.colors.backgroundLight};
5
+ padding-horizontal: ${(props : any) => props.isBusinessesSearchList ? '0' : '40px'};
6
+ `;