ordering-ui-react-native 0.15.58 → 0.15.60-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 (209) hide show
  1. package/package.json +6 -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/BusinessInformation/index.tsx +14 -0
  6. package/src/components/BusinessTypeFilter/index.tsx +3 -1
  7. package/src/components/BusinessesListing/index.tsx +1 -1
  8. package/src/components/Checkout/index.tsx +23 -2
  9. package/src/components/DriverTips/index.tsx +11 -6
  10. package/src/components/LanguageSelector/index.tsx +7 -2
  11. package/src/components/LoginForm/index.tsx +120 -30
  12. package/src/components/LoginForm/styles.tsx +6 -0
  13. package/src/components/OrderDetails/index.tsx +7 -21
  14. package/src/components/PaymentOptions/index.tsx +67 -50
  15. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  16. package/src/components/ReviewDriver/index.tsx +1 -1
  17. package/src/components/ReviewOrder/index.tsx +2 -1
  18. package/src/components/ReviewProducts/index.tsx +11 -0
  19. package/src/components/SignupForm/index.tsx +145 -61
  20. package/src/components/SingleProductCard/index.tsx +16 -4
  21. package/src/components/SingleProductReview/index.tsx +1 -1
  22. package/src/components/StripeMethodForm/index.tsx +1 -2
  23. package/src/components/UpsellingProducts/index.tsx +1 -1
  24. package/src/components/UserProfileForm/index.tsx +63 -6
  25. package/src/components/UserProfileForm/styles.tsx +8 -0
  26. package/src/components/VerifyPhone/styles.tsx +1 -2
  27. package/src/components/shared/OModal.tsx +1 -1
  28. package/src/hooks/useCountdownTimer.tsx +26 -0
  29. package/src/navigators/CheckoutNavigator.tsx +6 -0
  30. package/src/navigators/HomeNavigator.tsx +12 -0
  31. package/src/pages/BusinessesListing.tsx +8 -7
  32. package/src/pages/MultiCheckout.tsx +31 -0
  33. package/src/pages/MultiOrdersDetails.tsx +27 -0
  34. package/src/pages/OrderDetails.tsx +1 -1
  35. package/src/pages/ReviewDriver.tsx +2 -2
  36. package/src/pages/ReviewOrder.tsx +2 -2
  37. package/src/pages/Sessions.tsx +22 -0
  38. package/src/theme.json +0 -1
  39. package/src/types/index.tsx +18 -11
  40. package/src/utils/index.tsx +68 -1
  41. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  42. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  43. package/themes/business/src/components/Chat/index.tsx +42 -90
  44. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  45. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  46. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  47. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  48. package/themes/business/src/components/NewOrderNotification/index.tsx +26 -13
  49. package/themes/business/src/components/OrderDetails/Business.tsx +2 -2
  50. package/themes/business/src/components/OrderDetails/Delivery.tsx +28 -11
  51. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +41 -7
  52. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  53. package/themes/business/src/components/OrdersListManager/index.tsx +1 -1
  54. package/themes/business/src/components/OrdersOption/index.tsx +5 -2
  55. package/themes/business/src/components/PreviousOrders/index.tsx +7 -7
  56. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  57. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  58. package/themes/business/src/components/UserProfileForm/index.tsx +2 -0
  59. package/themes/business/src/components/shared/OModal.tsx +1 -1
  60. package/themes/business/src/types/index.tsx +6 -1
  61. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  62. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  63. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  64. package/themes/kiosk/src/components/BusinessMenu/index.tsx +39 -28
  65. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  66. package/themes/kiosk/src/components/Cart/index.tsx +11 -12
  67. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  68. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  69. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  70. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  71. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  72. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  73. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  74. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  75. package/themes/kiosk/src/components/NavBar/index.tsx +29 -20
  76. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  77. package/themes/kiosk/src/components/OrderDetails/index.tsx +32 -27
  78. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  79. package/themes/kiosk/src/components/PaymentOptions/index.tsx +56 -54
  80. package/themes/kiosk/src/components/ProductForm/index.tsx +7 -8
  81. package/themes/kiosk/src/components/ProductItemAccordion/index.tsx +2 -2
  82. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -1
  83. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  84. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  85. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  86. package/themes/kiosk/src/types/index.d.ts +1 -0
  87. package/themes/original/index.tsx +30 -8
  88. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  89. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  90. package/themes/original/src/components/AddressForm/index.tsx +7 -6
  91. package/themes/original/src/components/AddressList/index.tsx +30 -18
  92. package/themes/original/src/components/AppleLogin/index.tsx +9 -13
  93. package/themes/original/src/components/BusinessBasicInformation/index.tsx +137 -46
  94. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +4 -0
  95. package/themes/original/src/components/BusinessController/index.tsx +48 -11
  96. package/themes/original/src/components/BusinessController/styles.tsx +27 -0
  97. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  98. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  99. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
  100. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  101. package/themes/original/src/components/BusinessListingSearch/index.tsx +205 -61
  102. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  103. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  104. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  105. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  106. package/themes/original/src/components/BusinessProductsList/index.tsx +51 -53
  107. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  108. package/themes/original/src/components/BusinessProductsListing/index.tsx +301 -170
  109. package/themes/original/src/components/BusinessProductsListing/styles.tsx +27 -0
  110. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  111. package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -39
  112. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  113. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +557 -0
  114. package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +107 -0
  115. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +519 -0
  116. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Original/styles.tsx} +11 -3
  117. package/themes/original/src/components/BusinessesListing/index.tsx +97 -457
  118. package/themes/original/src/components/Cart/index.tsx +61 -42
  119. package/themes/original/src/components/Checkout/index.tsx +88 -38
  120. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  121. package/themes/original/src/components/Favorite/index.tsx +92 -0
  122. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  123. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  124. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  125. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  126. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  127. package/themes/original/src/components/GoogleMap/index.tsx +11 -11
  128. package/themes/original/src/components/Help/index.tsx +21 -4
  129. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  130. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  131. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
  132. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  133. package/themes/original/src/components/LoginForm/index.tsx +332 -164
  134. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  135. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  136. package/themes/original/src/components/Messages/index.tsx +1 -1
  137. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  138. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  139. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  140. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  141. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  142. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  143. package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
  144. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  145. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  146. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  147. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  148. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  149. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  150. package/themes/original/src/components/NavBar/index.tsx +4 -4
  151. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  152. package/themes/original/src/components/OrderDetails/index.tsx +151 -65
  153. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  154. package/themes/original/src/components/OrderSummary/index.tsx +3 -3
  155. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  156. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  157. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  158. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  159. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  160. package/themes/original/src/components/OrdersOption/index.tsx +130 -38
  161. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  162. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  163. package/themes/original/src/components/PaymentOptionWallet/index.tsx +17 -23
  164. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  165. package/themes/original/src/components/PaymentOptions/index.tsx +58 -37
  166. package/themes/original/src/components/PhoneInputNumber/index.tsx +5 -11
  167. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  168. package/themes/original/src/components/ProductForm/index.tsx +70 -62
  169. package/themes/original/src/components/ProductForm/styles.tsx +0 -1
  170. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  171. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  172. package/themes/original/src/components/ProfessionalFilter/index.tsx +128 -0
  173. package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
  174. package/themes/original/src/components/ProfessionalProfile/index.tsx +298 -0
  175. package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
  176. package/themes/original/src/components/Promotions/index.tsx +151 -133
  177. package/themes/original/src/components/Promotions/styles.tsx +3 -23
  178. package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
  179. package/themes/original/src/components/ReviewOrder/index.tsx +1 -1
  180. package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
  181. package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
  182. package/themes/original/src/components/SearchBar/index.tsx +10 -4
  183. package/themes/original/src/components/ServiceForm/index.tsx +579 -0
  184. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  185. package/themes/original/src/components/Sessions/index.tsx +160 -0
  186. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  187. package/themes/original/src/components/SignupForm/index.tsx +237 -126
  188. package/themes/original/src/components/SingleOrderCard/index.tsx +282 -0
  189. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  190. package/themes/original/src/components/SingleProductCard/index.tsx +59 -17
  191. package/themes/original/src/components/StripeElementsForm/index.tsx +16 -8
  192. package/themes/original/src/components/StripeElementsForm/naked.tsx +2 -2
  193. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  194. package/themes/original/src/components/UserDetails/index.tsx +15 -81
  195. package/themes/original/src/components/UserFormDetails/index.tsx +98 -66
  196. package/themes/original/src/components/UserProfile/index.tsx +52 -5
  197. package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
  198. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  199. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  200. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  201. package/themes/original/src/components/Wallets/index.tsx +76 -9
  202. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  203. package/themes/original/src/components/shared/OBottomPopup.tsx +44 -13
  204. package/themes/original/src/components/shared/OModal.tsx +4 -2
  205. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  206. package/themes/original/src/types/index.tsx +186 -35
  207. package/themes/original/src/utils/index.tsx +96 -2
  208. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
  209. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -0,0 +1,519 @@
1
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
3
+ import Geolocation from '@react-native-community/geolocation'
4
+ import { getTrackingStatus, requestTrackingPermission } from 'react-native-tracking-transparency'
5
+ import {
6
+ View,
7
+ StyleSheet,
8
+ ScrollView,
9
+ Platform,
10
+ TouchableOpacity,
11
+ RefreshControl,
12
+ AppState
13
+ } from 'react-native';
14
+ import {
15
+ BusinessList as BusinessesListingController,
16
+ useLanguage,
17
+ useSession,
18
+ useOrder,
19
+ useConfig,
20
+ useUtils,
21
+ } from 'ordering-components/native';
22
+ import { useTheme } from 'styled-components/native';
23
+ import Ionicons from 'react-native-vector-icons/Ionicons'
24
+
25
+ import {
26
+ Search,
27
+ OrderControlContainer,
28
+ AddressInput,
29
+ WrapMomentOption,
30
+ HeaderWrapper,
31
+ ListWrapper,
32
+ FeaturedWrapper,
33
+ OrderProgressWrapper,
34
+ FarAwayMessage,
35
+ AddressInputContainer
36
+ } from './styles';
37
+
38
+ import { SearchBar } from '../../../SearchBar';
39
+ import { OIcon, OText } from '../../../shared';
40
+ import { BusinessesListingParams } from '../../../../types';
41
+ import { NotFoundSource } from '../../../NotFoundSource';
42
+ import { BusinessTypeFilter } from '../../../BusinessTypeFilter';
43
+ import { BusinessController } from '../../../BusinessController';
44
+ import { OrderTypeSelector } from '../../../OrderTypeSelector';
45
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
46
+ import { BusinessFeaturedController } from '../../../BusinessFeaturedController';
47
+ import { HighestRatedBusinesses } from '../../../HighestRatedBusinesses';
48
+ import { getTypesText, convertToRadian } from '../../../../utils';
49
+ import { OrderProgress } from '../../../OrderProgress';
50
+ import { useFocusEffect, useIsFocused } from '@react-navigation/native';
51
+
52
+ const PIXELS_TO_SCROLL = 2000;
53
+
54
+ const BusinessesListingUI = (props: BusinessesListingParams) => {
55
+ const {
56
+ navigation,
57
+ businessesList,
58
+ searchValue,
59
+ getBusinesses,
60
+ handleChangeBusinessType,
61
+ handleBusinessClick,
62
+ paginationProps,
63
+ handleChangeSearch,
64
+ businessId,
65
+ isGuestUser,
66
+ handleUpdateBusinessList
67
+ } = props;
68
+ const theme = useTheme();
69
+ const isFocused = useIsFocused();
70
+ const appState = useRef(AppState.currentState)
71
+ const [appStateVisible, setAppStateVisible] = useState(appState.current);
72
+ const [refreshing] = useState(false);
73
+ const styles = StyleSheet.create({
74
+ container: {
75
+ marginBottom: 0,
76
+ },
77
+ welcome: {
78
+ flex: 1,
79
+ flexDirection: 'row',
80
+ },
81
+ inputStyle: {
82
+ backgroundColor: theme.colors.inputDisabled,
83
+ flex: 1,
84
+ },
85
+ wrapperOrderOptions: {
86
+ width: '100%',
87
+ flexDirection: 'row',
88
+ justifyContent: 'center',
89
+ marginBottom: 10,
90
+ zIndex: 100,
91
+ },
92
+ borderStyle: {
93
+ borderColor: theme.colors.backgroundGray,
94
+ borderWidth: 1,
95
+ borderRadius: 10,
96
+ },
97
+ searchInput: {
98
+ fontSize: 16,
99
+ backgroundColor: theme.colors.white,
100
+ paddingLeft: 10,
101
+ paddingTop: 7
102
+ },
103
+ iconStyle: {
104
+ fontSize: 18,
105
+ color: theme.colors.warning5,
106
+ marginRight: 8
107
+ },
108
+ farAwayMsg: {
109
+ paddingVertical: 6,
110
+ paddingHorizontal: 20
111
+ },
112
+ inputContainerStyles: {
113
+ backgroundColor: theme.colors.white,
114
+ borderColor: theme.colors.backgroundGray,
115
+ borderWidth: 1,
116
+ }
117
+ });
118
+
119
+
120
+ const [, t] = useLanguage();
121
+ const [{ user, auth }] = useSession();
122
+ const [orderState] = useOrder();
123
+ const [{ configs }] = useConfig();
124
+ const [{ parseDate }] = useUtils();
125
+
126
+ const { top } = useSafeAreaInsets();
127
+
128
+ const [featuredBusiness, setFeaturedBusinesses] = useState(Array);
129
+ const [isFarAway, setIsFarAway] = useState(false)
130
+ const [businessTypes, setBusinessTypes] = useState(null)
131
+ const [orderTypeValue, setOrderTypeValue] = useState(orderState?.options.value)
132
+ const isPreorderEnabled = (configs?.preorder_status_enabled?.value === '1' || configs?.preorder_status_enabled?.value === 'true') &&
133
+ Number(configs?.max_days_preorder?.value) > 0
134
+ const isPreOrderSetting = configs?.preorder_status_enabled?.value === '1'
135
+ const timerId = useRef<any>(false)
136
+ const [favoriteIds, setFavoriteIds] = useState<any>([])
137
+
138
+ // const panResponder = useRef(
139
+ // PanResponder.create({
140
+ // onMoveShouldSetPanResponder: (e, gestureState) => {
141
+ // const { dx, dy } = gestureState;
142
+ // resetInactivityTimeout()
143
+ // return (Math.abs(dx) > 20) || (Math.abs(dy) > 20);
144
+ // },
145
+ // })
146
+ // ).current
147
+
148
+ const handleMomentClick = () => {
149
+ if (isPreorderEnabled) {
150
+ navigation.navigate('MomentOption')
151
+ }
152
+ }
153
+
154
+ const configTypes =
155
+ configs?.order_types_allowed?.value
156
+ .split('|')
157
+ .map((value: any) => Number(value)) || [];
158
+
159
+ const handleScroll = ({ nativeEvent }: any) => {
160
+ const y = nativeEvent.contentOffset.y;
161
+ const height = nativeEvent.contentSize.height;
162
+ const hasMore = !(
163
+ paginationProps.totalPages === paginationProps.currentPage
164
+ );
165
+
166
+ if (y + PIXELS_TO_SCROLL > height && !businessesList.loading && hasMore) {
167
+ getBusinesses();
168
+ }
169
+ };
170
+
171
+ const getDistance = (lat1: any, lon1: any, lat2: any, lon2: any) => {
172
+ const R = 6371 // km
173
+ const dLat = convertToRadian(lat2 - lat1)
174
+ const dLon = convertToRadian(lon2 - lon1)
175
+ const curLat1 = convertToRadian(lat1)
176
+ const curLat2 = convertToRadian(lat2)
177
+ const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(curLat1) * Math.cos(curLat2)
178
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
179
+ return R * c
180
+ }
181
+
182
+ const resetInactivityTimeout = () => {
183
+ clearTimeout(timerId.current)
184
+ timerId.current = setInterval(() => {
185
+ getBusinesses(true)
186
+ }, 120000)
187
+ }
188
+
189
+ useEffect(() => {
190
+ if (!businessesList?.loading) {
191
+ const fb = businessesList.businesses.filter((b) => b.featured === true && b?.open);
192
+ const ary = [];
193
+ while (fb.length > 0) {
194
+ ary.push(fb.splice(0, 2));
195
+ }
196
+ setFeaturedBusinesses(ary);
197
+ }
198
+ resetInactivityTimeout()
199
+ }, [businessesList.loading])
200
+
201
+ const handleOnRefresh = () => {
202
+ if (!businessesList.loading) {
203
+ getBusinesses(true);
204
+ }
205
+ }
206
+
207
+ const checkUserLocation = async () => {
208
+ let trackingStatus = await getTrackingStatus()
209
+ if (trackingStatus === 'not-determined') {
210
+ trackingStatus = await requestTrackingPermission()
211
+ }
212
+ if (trackingStatus === 'authorized' || trackingStatus === 'unavailable') {
213
+ Geolocation.getCurrentPosition((pos) => {
214
+ const crd = pos.coords
215
+ const distance = getDistance(crd.latitude, crd.longitude, orderState?.options?.address?.location?.lat, orderState?.options?.address?.location?.lng)
216
+ if (distance > 20) setIsFarAway(true)
217
+ else setIsFarAway(false)
218
+ }, (err) => {
219
+ console.log(`ERROR(${err.code}): ${err.message}`)
220
+ }, {
221
+ enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
222
+ })
223
+ }
224
+ }
225
+
226
+ useEffect(() => {
227
+ checkUserLocation()
228
+ }, [orderState?.options?.address?.location])
229
+
230
+ useEffect(() => {
231
+ if (!orderState?.loading) {
232
+ setOrderTypeValue(orderState?.options?.type)
233
+ }
234
+ }, [orderState?.options?.type])
235
+
236
+ useFocusEffect(
237
+ useCallback(() => {
238
+ resetInactivityTimeout()
239
+ return () => clearTimeout(timerId.current)
240
+ }, [navigation])
241
+ )
242
+
243
+ useEffect(() => {
244
+ if (!businessesList?.businesses?.length) return
245
+ const ids = [...favoriteIds]
246
+ businessesList.businesses.forEach((business: any) => {
247
+ if (business?.favorite) {
248
+ ids.push(business?.id)
249
+ }
250
+ })
251
+ setFavoriteIds([...new Set(ids)])
252
+ }, [businessesList?.businesses?.length])
253
+
254
+ return (
255
+ <ScrollView style={styles.container} onScroll={(e) => handleScroll(e)} showsVerticalScrollIndicator={false}
256
+ refreshControl={
257
+ <RefreshControl
258
+ refreshing={refreshing}
259
+ onRefresh={() => handleOnRefresh()}
260
+ />
261
+ }
262
+ >
263
+ <View style={{ height: isFarAway ? 150 : 100, marginTop: Platform.OS == 'ios' ? 0 : 50 }}>
264
+ <Search>
265
+ <AddressInput
266
+ onPress={() =>
267
+ auth
268
+ ? navigation.navigate('AddressList', { isFromBusinesses: true })
269
+ : navigation.navigate('AddressForm', {
270
+ address: orderState.options?.address,
271
+ isFromBusinesses: true,
272
+ isGuestUser: isGuestUser
273
+ })
274
+ }>
275
+ <AddressInputContainer>
276
+ <OIcon
277
+ src={theme.images.general.pin}
278
+ color={theme.colors.disabled}
279
+ width={16}
280
+ style={{ marginRight: 10 }}
281
+ />
282
+ <OText size={12} numberOfLines={1}>
283
+ {orderState?.options?.address?.address}
284
+ </OText>
285
+ <OIcon
286
+ src={theme.images.general.arrow_down}
287
+ width={10}
288
+ style={{ marginStart: 8 }}
289
+ />
290
+ </AddressInputContainer>
291
+ </AddressInput>
292
+ </Search>
293
+ {isFarAway && (
294
+ <FarAwayMessage style={styles.farAwayMsg}>
295
+ <Ionicons name='md-warning-outline' style={styles.iconStyle} />
296
+ <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'You are far from this address')}</OText>
297
+ </FarAwayMessage>
298
+ )}
299
+
300
+ <OrderControlContainer>
301
+ <View style={styles.wrapperOrderOptions}>
302
+ {isPreOrderSetting && (
303
+ <WrapMomentOption
304
+ onPress={() => handleMomentClick()}>
305
+ <OText
306
+ size={12}
307
+ numberOfLines={1}
308
+ ellipsizeMode="tail"
309
+ color={theme.colors.textSecondary}>
310
+ {orderState.options?.moment
311
+ ? parseDate(orderState.options?.moment, { outputFormat: configs?.dates_moment_format?.value })
312
+ : t('ASAP_ABBREVIATION', 'ASAP')}
313
+ </OText>
314
+ {isPreorderEnabled && (
315
+ <OIcon
316
+ src={theme.images.general.arrow_down}
317
+ width={10}
318
+ style={{ marginStart: 8 }}
319
+ />
320
+ )}
321
+ </WrapMomentOption>
322
+ )}
323
+ <WrapMomentOption onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes, setOrderTypeValue })}>
324
+ <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textSecondary}>{t(getTypesText(orderTypeValue || orderState?.options?.type || 1), 'Delivery')}</OText>
325
+ <OIcon
326
+ src={theme.images.general.arrow_down}
327
+ width={10}
328
+ style={{ marginStart: 8 }}
329
+ />
330
+ </WrapMomentOption>
331
+ </View>
332
+ </OrderControlContainer>
333
+ </View>
334
+ <HeaderWrapper
335
+ source={theme.images.backgrounds.business_list_header}
336
+ style={{ paddingTop: top + 20 }}
337
+ resizeMode='stretch'
338
+ >
339
+ {!auth && (
340
+ <TouchableOpacity onPress={() => navigation?.canGoBack() && navigation.goBack()} style={{ position: 'absolute', marginStart: 40, paddingVertical: 20 }}>
341
+ <OIcon src={theme.images.general.arrow_left} width={20} style={{ tintColor: theme.colors.white }} />
342
+ </TouchableOpacity>
343
+ )}
344
+ </HeaderWrapper>
345
+ {!businessId && (
346
+ <SearchBar
347
+ onSearch={handleChangeSearch}
348
+ searchValue={searchValue}
349
+ lazyLoad
350
+ hideIcon
351
+ isCancelXButtonShow={!!searchValue}
352
+ onCancel={() => handleChangeSearch('')}
353
+ placeholder={t('SEARCH', 'Search')}
354
+ height={50}
355
+ isDisabled={!businessTypes}
356
+ inputContainerStyles={styles.inputContainerStyles}
357
+ containerStyles={{
358
+ marginHorizontal: 40,
359
+ marginTop: 20
360
+ }}
361
+ inputStyle={{ ...styles.searchInput, ...Platform.OS === 'ios' ? { paddingBottom: 6 } : { paddingBottom: 4 } }}
362
+ onSubmitEditing={() => { configs?.advanced_business_search_enabled?.value === '1' && navigation.navigate('BusinessSearch', { businessTypes, defaultTerm: searchValue }) }}
363
+ />
364
+ )}
365
+ <OrderProgressWrapper>
366
+ <OrderProgress
367
+ {...props}
368
+ isFocused={isFocused}
369
+ />
370
+ </OrderProgressWrapper>
371
+
372
+ {
373
+ !businessId && !props.franchiseId && featuredBusiness && featuredBusiness.length > 0 && (
374
+ <FeaturedWrapper>
375
+ <OText size={16} style={{ marginLeft: 40 }} weight={Platform.OS === 'ios' ? '600' : 'bold'}>{t('BUSINESS_FEATURE', 'Featured business')}</OText>
376
+ <ScrollView
377
+ showsHorizontalScrollIndicator={false}
378
+ nestedScrollEnabled
379
+ horizontal contentContainerStyle={{ paddingHorizontal: 40 }}>
380
+ {featuredBusiness.map((bAry: any, idx) => (
381
+ <View key={'f-listing_' + idx}>
382
+ <BusinessFeaturedController
383
+ business={bAry[0]}
384
+ isBusinessOpen={bAry[0]?.open}
385
+ handleCustomClick={handleBusinessClick}
386
+ orderType={orderState?.options?.type}
387
+ />
388
+ {bAry.length > 1 && (
389
+ <BusinessFeaturedController
390
+ business={bAry[1]}
391
+ isBusinessOpen={bAry[1]?.open}
392
+ handleCustomClick={handleBusinessClick}
393
+ orderType={orderState?.options?.type}
394
+ />
395
+ )}
396
+ </View>
397
+ ))}
398
+ </ScrollView>
399
+ </FeaturedWrapper>
400
+ )
401
+ }
402
+ <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
403
+ {
404
+ !businessId && !props.franchiseId && (
405
+ <HighestRatedBusinesses
406
+ onBusinessClick={handleBusinessClick}
407
+ navigation={navigation}
408
+ favoriteIds={favoriteIds}
409
+ setFavoriteIds={setFavoriteIds}
410
+ />
411
+ )
412
+ }
413
+ <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
414
+ <ListWrapper>
415
+ {!businessId && (
416
+ <BusinessTypeFilter
417
+ images={props.images}
418
+ businessTypes={props.businessTypes}
419
+ defaultBusinessType={props.defaultBusinessType}
420
+ handleChangeBusinessType={handleChangeBusinessType}
421
+ setBusinessTypes={setBusinessTypes}
422
+ />
423
+ )}
424
+ {!businessesList.loading && businessesList.businesses.length === 0 && (
425
+ <NotFoundSource
426
+ content={t(
427
+ 'NOT_FOUND_BUSINESSES',
428
+ 'No businesses to delivery / pick up at this address, please change filters or change address.',
429
+ )}
430
+ />
431
+ )}
432
+ {businessesList.businesses?.map(
433
+ (business: any, i: number) => (
434
+ <BusinessController
435
+ key={`${business.id}_` + i}
436
+ business={business}
437
+ isBusinessOpen={business.open}
438
+ handleCustomClick={handleBusinessClick}
439
+ orderType={orderState?.options?.type}
440
+ navigation={navigation}
441
+ businessHeader={business?.header}
442
+ businessFeatured={business?.featured}
443
+ businessLogo={business?.logo}
444
+ businessReviews={business?.reviews}
445
+ businessDeliveryPrice={business?.delivery_price}
446
+ businessDeliveryTime={business?.delivery_time}
447
+ businessPickupTime={business?.pickup_time}
448
+ businessDistance={business?.distance}
449
+ handleUpdateBusinessList={handleUpdateBusinessList}
450
+ favoriteIds={favoriteIds}
451
+ setFavoriteIds={setFavoriteIds}
452
+ />
453
+ )
454
+ )}
455
+ {businessesList.loading && (
456
+ <>
457
+ {[
458
+ ...Array(
459
+ paginationProps.nextPageItems
460
+ ? paginationProps.nextPageItems
461
+ : 8,
462
+ ).keys(),
463
+ ].map((item, i) => (
464
+ <Placeholder
465
+ Animation={Fade}
466
+ key={i}
467
+ style={{ marginBottom: 20 }}>
468
+ <View style={{ width: '100%' }}>
469
+ <PlaceholderLine
470
+ height={200}
471
+ style={{ marginBottom: 20, borderRadius: 25 }}
472
+ />
473
+ <View style={{ paddingHorizontal: 10 }}>
474
+ <View
475
+ style={{
476
+ flexDirection: 'row',
477
+ justifyContent: 'space-between',
478
+ }}>
479
+ <PlaceholderLine
480
+ height={25}
481
+ width={40}
482
+ style={{ marginBottom: 10 }}
483
+ />
484
+ <PlaceholderLine
485
+ height={25}
486
+ width={20}
487
+ style={{ marginBottom: 10 }}
488
+ />
489
+ </View>
490
+ <PlaceholderLine
491
+ height={20}
492
+ width={30}
493
+ style={{ marginBottom: 10 }}
494
+ />
495
+ <PlaceholderLine
496
+ height={20}
497
+ width={80}
498
+ style={{ marginBottom: 10 }}
499
+ />
500
+ </View>
501
+ </View>
502
+ </Placeholder>
503
+ ))}
504
+ </>
505
+ )}
506
+ </ListWrapper>
507
+ </ScrollView>
508
+ );
509
+ };
510
+
511
+ export const BusinessesListing = (props: BusinessesListingParams) => {
512
+ const BusinessesListingProps = {
513
+ ...props,
514
+ isForceSearch: Platform.OS === 'ios',
515
+ UIComponent: BusinessesListingUI,
516
+ };
517
+
518
+ return <BusinessesListingController {...BusinessesListingProps} />;
519
+ };
@@ -15,6 +15,7 @@ export const Search = styled.View`
15
15
  justify-content: flex-end;
16
16
  align-items: center;
17
17
  margin-vertical: 10px;
18
+ margin-horizontal: 20px;
18
19
  `
19
20
 
20
21
  export const AddressInput = styled.TouchableOpacity`
@@ -39,7 +40,7 @@ export const OrderControlContainer = styled.View`
39
40
  `
40
41
 
41
42
  export const WrapMomentOption = styled.TouchableOpacity`
42
- background-color: ${(props: any) => props.theme.colors.backgroundGray100};
43
+ background-color: ${(props: any) => props.theme.colors.white};
43
44
  border-radius: 7.6px;
44
45
  font-size: 12px;
45
46
  max-width: 240px;
@@ -53,7 +54,7 @@ export const WrapMomentOption = styled.TouchableOpacity`
53
54
 
54
55
  export const HeaderWrapper = styled.ImageBackground`
55
56
  width: 100%;
56
- height: 370px;
57
+ height: 270px;
57
58
  padding: 20px 40px;
58
59
  background-color: transparent;
59
60
  `;
@@ -79,7 +80,14 @@ export const FarAwayMessage = styled.View`
79
80
  flex-direction: row;
80
81
  align-items: center;
81
82
  background-color: ${(props: any) => props.theme.colors.warning1};
82
- margin-bottom: 25px;
83
+ margin-bottom: 10px;
83
84
  border-radius: 7.6px;
84
85
  border: 1px solid ${(props: any) => props.theme.colors.warning5};
85
86
  `
87
+
88
+ export const AddressInputContainer = styled.View`
89
+ flex-direction: row;
90
+ width: 100%;
91
+ align-items: center;
92
+ justify-content: center
93
+ `