ordering-ui-react-native 0.15.62 → 0.15.63-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 (210) hide show
  1. package/package.json +7 -3
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/AddressForm/index.tsx +18 -2
  4. package/src/components/BusinessBasicInformation/index.tsx +11 -19
  5. package/src/components/BusinessController/index.tsx +16 -8
  6. package/src/components/BusinessInformation/index.tsx +14 -0
  7. package/src/components/BusinessTypeFilter/index.tsx +1 -2
  8. package/src/components/BusinessesListing/index.tsx +1 -1
  9. package/src/components/Checkout/index.tsx +23 -2
  10. package/src/components/DriverTips/index.tsx +11 -6
  11. package/src/components/LanguageSelector/index.tsx +6 -2
  12. package/src/components/LoginForm/index.tsx +120 -30
  13. package/src/components/LoginForm/styles.tsx +6 -0
  14. package/src/components/OrderDetails/index.tsx +7 -21
  15. package/src/components/PaymentOptions/index.tsx +67 -50
  16. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  17. package/src/components/ReviewDriver/index.tsx +1 -1
  18. package/src/components/ReviewOrder/index.tsx +2 -1
  19. package/src/components/ReviewProducts/index.tsx +11 -0
  20. package/src/components/SignupForm/index.tsx +145 -61
  21. package/src/components/SingleProductCard/index.tsx +16 -4
  22. package/src/components/SingleProductReview/index.tsx +1 -1
  23. package/src/components/StripeMethodForm/index.tsx +22 -24
  24. package/src/components/UpsellingProducts/index.tsx +1 -1
  25. package/src/components/UserProfileForm/index.tsx +63 -6
  26. package/src/components/UserProfileForm/styles.tsx +8 -0
  27. package/src/components/VerifyPhone/styles.tsx +1 -2
  28. package/src/components/shared/OModal.tsx +1 -1
  29. package/src/hooks/useCountdownTimer.tsx +26 -0
  30. package/src/navigators/CheckoutNavigator.tsx +6 -0
  31. package/src/navigators/HomeNavigator.tsx +12 -0
  32. package/src/pages/BusinessesListing.tsx +7 -6
  33. package/src/pages/MultiCheckout.tsx +31 -0
  34. package/src/pages/MultiOrdersDetails.tsx +27 -0
  35. package/src/pages/OrderDetails.tsx +1 -1
  36. package/src/pages/ReviewDriver.tsx +2 -2
  37. package/src/pages/ReviewOrder.tsx +2 -2
  38. package/src/pages/Sessions.tsx +22 -0
  39. package/src/theme.json +0 -1
  40. package/src/types/index.tsx +18 -11
  41. package/src/utils/index.tsx +68 -1
  42. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  43. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  44. package/themes/business/src/components/Chat/index.tsx +42 -90
  45. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  46. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  47. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  48. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  49. package/themes/business/src/components/NewOrderNotification/index.tsx +26 -13
  50. package/themes/business/src/components/OrderDetails/Business.tsx +2 -2
  51. package/themes/business/src/components/OrderDetails/Delivery.tsx +28 -11
  52. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +14 -7
  53. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  54. package/themes/business/src/components/OrdersListManager/index.tsx +1 -1
  55. package/themes/business/src/components/OrdersOption/index.tsx +8 -4
  56. package/themes/business/src/components/PreviousOrders/index.tsx +7 -7
  57. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  58. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  59. package/themes/business/src/components/UserProfileForm/index.tsx +2 -0
  60. package/themes/business/src/components/shared/OModal.tsx +1 -1
  61. package/themes/business/src/types/index.tsx +8 -2
  62. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  63. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  64. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  65. package/themes/kiosk/src/components/BusinessMenu/index.tsx +39 -28
  66. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -3
  67. package/themes/kiosk/src/components/Cart/index.tsx +11 -12
  68. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +9 -2
  69. package/themes/kiosk/src/components/CartContent/index.tsx +0 -11
  70. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  71. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +107 -62
  72. package/themes/kiosk/src/components/Checkout/index.tsx +40 -22
  73. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  74. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  75. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  76. package/themes/kiosk/src/components/NavBar/index.tsx +29 -20
  77. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  78. package/themes/kiosk/src/components/OrderDetails/index.tsx +32 -27
  79. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +9 -11
  80. package/themes/kiosk/src/components/PaymentOptions/index.tsx +56 -54
  81. package/themes/kiosk/src/components/ProductForm/index.tsx +7 -8
  82. package/themes/kiosk/src/components/ProductItemAccordion/index.tsx +2 -2
  83. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -1
  84. package/themes/kiosk/src/components/ProductOptionSubOption/index.tsx +3 -1
  85. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +16 -5
  86. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  87. package/themes/kiosk/src/types/index.d.ts +1 -0
  88. package/themes/original/index.tsx +30 -8
  89. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  90. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  91. package/themes/original/src/components/AddressForm/index.tsx +7 -6
  92. package/themes/original/src/components/AddressList/index.tsx +30 -18
  93. package/themes/original/src/components/AppleLogin/index.tsx +7 -12
  94. package/themes/original/src/components/BusinessBasicInformation/index.tsx +137 -46
  95. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +4 -0
  96. package/themes/original/src/components/BusinessController/index.tsx +168 -96
  97. package/themes/original/src/components/BusinessController/styles.tsx +5 -0
  98. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -5
  99. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -1
  100. package/themes/original/src/components/BusinessListingSearch/index.tsx +231 -63
  101. package/themes/original/src/components/BusinessListingSearch/styles.tsx +22 -2
  102. package/themes/original/src/components/BusinessPreorder/index.tsx +1 -1
  103. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -2
  104. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  105. package/themes/original/src/components/BusinessProductsList/index.tsx +51 -52
  106. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  107. package/themes/original/src/components/BusinessProductsListing/index.tsx +291 -155
  108. package/themes/original/src/components/BusinessProductsListing/styles.tsx +27 -0
  109. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  110. package/themes/original/src/components/BusinessTypeFilter/index.tsx +106 -39
  111. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  112. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +560 -0
  113. package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +107 -0
  114. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +559 -0
  115. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Original/styles.tsx} +11 -3
  116. package/themes/original/src/components/BusinessesListing/index.tsx +99 -458
  117. package/themes/original/src/components/Cart/index.tsx +62 -43
  118. package/themes/original/src/components/Checkout/index.tsx +90 -39
  119. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  120. package/themes/original/src/components/Favorite/index.tsx +92 -0
  121. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  122. package/themes/original/src/components/FavoriteList/index.tsx +298 -0
  123. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  124. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  125. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  126. package/themes/original/src/components/GoogleMap/index.tsx +11 -11
  127. package/themes/original/src/components/Help/index.tsx +21 -4
  128. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  129. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  130. package/themes/original/src/components/LoginForm/Otp/index.tsx +91 -0
  131. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  132. package/themes/original/src/components/LoginForm/index.tsx +332 -164
  133. package/themes/original/src/components/LoginForm/styles.tsx +1 -3
  134. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  135. package/themes/original/src/components/Messages/index.tsx +1 -1
  136. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  137. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  138. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  139. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  140. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +243 -0
  141. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/styles.tsx +46 -0
  142. package/themes/original/src/components/MultiCheckout/index.tsx +298 -0
  143. package/themes/original/src/components/MultiCheckout/styles.tsx +59 -0
  144. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +372 -0
  145. package/themes/original/src/components/MultiOrdersDetails/index.tsx +258 -0
  146. package/themes/original/src/components/MultiOrdersDetails/styles.tsx +50 -0
  147. package/themes/original/src/components/MyOrders/index.tsx +120 -32
  148. package/themes/original/src/components/MyOrders/styles.tsx +8 -1
  149. package/themes/original/src/components/NavBar/index.tsx +4 -4
  150. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  151. package/themes/original/src/components/OrderDetails/index.tsx +151 -65
  152. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  153. package/themes/original/src/components/OrderSummary/index.tsx +6 -6
  154. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  155. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +153 -0
  156. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +6 -0
  157. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +53 -0
  158. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +6 -0
  159. package/themes/original/src/components/OrdersOption/index.tsx +137 -38
  160. package/themes/original/src/components/OrdersOption/styles.tsx +4 -1
  161. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  162. package/themes/original/src/components/PaymentOptionWallet/index.tsx +17 -23
  163. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  164. package/themes/original/src/components/PaymentOptions/index.tsx +58 -37
  165. package/themes/original/src/components/PhoneInputNumber/index.tsx +5 -11
  166. package/themes/original/src/components/PreviousOrders/index.tsx +18 -147
  167. package/themes/original/src/components/ProductForm/index.tsx +718 -679
  168. package/themes/original/src/components/ProductForm/styles.tsx +6 -2
  169. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  170. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  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 +13 -5
  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 +275 -0
  189. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  190. package/themes/original/src/components/SingleProductCard/index.tsx +150 -84
  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 +11 -2
  197. package/themes/original/src/components/UserProfileForm/index.tsx +33 -22
  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/OInput.tsx +3 -2
  205. package/themes/original/src/components/shared/OModal.tsx +4 -2
  206. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  207. package/themes/original/src/types/index.tsx +184 -35
  208. package/themes/original/src/utils/index.tsx +96 -2
  209. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +1 -1
  210. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -0,0 +1,559 @@
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 { IOScrollView } from 'react-native-intersection-observer'
5
+ import { getTrackingStatus, requestTrackingPermission } from 'react-native-tracking-transparency'
6
+ import {
7
+ View,
8
+ StyleSheet,
9
+ ScrollView,
10
+ Platform,
11
+ TouchableOpacity,
12
+ RefreshControl,
13
+ AppState
14
+ } from 'react-native';
15
+ import {
16
+ BusinessList as BusinessesListingController,
17
+ useLanguage,
18
+ useSession,
19
+ useOrder,
20
+ useConfig,
21
+ useUtils,
22
+ } from 'ordering-components/native';
23
+ import { useTheme } from 'styled-components/native';
24
+ import Ionicons from 'react-native-vector-icons/Ionicons'
25
+
26
+ import {
27
+ Search,
28
+ OrderControlContainer,
29
+ AddressInput,
30
+ WrapMomentOption,
31
+ HeaderWrapper,
32
+ ListWrapper,
33
+ FeaturedWrapper,
34
+ OrderProgressWrapper,
35
+ FarAwayMessage,
36
+ AddressInputContainer
37
+ } from './styles';
38
+
39
+ import { SearchBar } from '../../../SearchBar';
40
+ import { OIcon, OText } from '../../../shared';
41
+ import { BusinessesListingParams } from '../../../../types';
42
+ import { NotFoundSource } from '../../../NotFoundSource';
43
+ import { BusinessTypeFilter } from '../../../BusinessTypeFilter';
44
+ import { BusinessController } from '../../../BusinessController';
45
+ import { OrderTypeSelector } from '../../../OrderTypeSelector';
46
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
47
+ import { BusinessFeaturedController } from '../../../BusinessFeaturedController';
48
+ import { HighestRatedBusinesses } from '../../../HighestRatedBusinesses';
49
+ import { getTypesText, convertToRadian } from '../../../../utils';
50
+ import { OrderProgress } from '../../../OrderProgress';
51
+ import { useFocusEffect, useIsFocused } from '@react-navigation/native';
52
+
53
+ const PIXELS_TO_SCROLL = 2000;
54
+
55
+ const BusinessesListingUI = (props: BusinessesListingParams) => {
56
+ const {
57
+ navigation,
58
+ businessesList,
59
+ searchValue,
60
+ getBusinesses,
61
+ handleChangeBusinessType,
62
+ handleBusinessClick,
63
+ paginationProps,
64
+ handleChangeSearch,
65
+ businessId,
66
+ isGuestUser,
67
+ handleUpdateBusinessList
68
+ } = props;
69
+ const theme = useTheme();
70
+ const isFocused = useIsFocused();
71
+ const appState = useRef(AppState.currentState)
72
+ const [appStateVisible, setAppStateVisible] = useState(appState.current);
73
+ const [refreshing] = useState(false);
74
+ const styles = StyleSheet.create({
75
+ container: {
76
+ marginBottom: 0,
77
+ },
78
+ welcome: {
79
+ flex: 1,
80
+ flexDirection: 'row',
81
+ },
82
+ inputStyle: {
83
+ backgroundColor: theme.colors.inputDisabled,
84
+ flex: 1,
85
+ },
86
+ wrapperOrderOptions: {
87
+ width: '100%',
88
+ flexDirection: 'row',
89
+ justifyContent: 'center',
90
+ marginBottom: 10,
91
+ zIndex: 100,
92
+ },
93
+ borderStyle: {
94
+ borderColor: theme.colors.backgroundGray,
95
+ borderWidth: 1,
96
+ borderRadius: 10,
97
+ },
98
+ searchInput: {
99
+ fontSize: 16,
100
+ backgroundColor: theme.colors.white,
101
+ paddingLeft: 10,
102
+ paddingTop: 7
103
+ },
104
+ iconStyle: {
105
+ fontSize: 18,
106
+ color: theme.colors.warning5,
107
+ marginRight: 8
108
+ },
109
+ farAwayMsg: {
110
+ paddingVertical: 6,
111
+ paddingHorizontal: 20
112
+ },
113
+ inputContainerStyles: {
114
+ backgroundColor: theme.colors.white,
115
+ borderColor: theme.colors.backgroundGray,
116
+ borderWidth: 1,
117
+ }
118
+ });
119
+
120
+
121
+ const [, t] = useLanguage();
122
+ const [{ user, auth }] = useSession();
123
+ const [orderState] = useOrder();
124
+ const [{ configs }] = useConfig();
125
+ const [{ parseDate }] = useUtils();
126
+
127
+ const { top } = useSafeAreaInsets();
128
+
129
+ const [featuredBusiness, setFeaturedBusinesses] = useState(Array);
130
+ const [isFarAway, setIsFarAway] = useState(false)
131
+ const [businessTypes, setBusinessTypes] = useState(null)
132
+ const [orderTypeValue, setOrderTypeValue] = useState(orderState?.options.value)
133
+ const isPreorderEnabled = (configs?.preorder_status_enabled?.value === '1' || configs?.preorder_status_enabled?.value === 'true') &&
134
+ Number(configs?.max_days_preorder?.value) > 0
135
+ const isPreOrderSetting = configs?.preorder_status_enabled?.value === '1'
136
+ const timerId = useRef<any>(false)
137
+ const [favoriteIds, setFavoriteIds] = useState<any>([])
138
+
139
+ // const panResponder = useRef(
140
+ // PanResponder.create({
141
+ // onMoveShouldSetPanResponder: (e, gestureState) => {
142
+ // const { dx, dy } = gestureState;
143
+ // resetInactivityTimeout()
144
+ // return (Math.abs(dx) > 20) || (Math.abs(dy) > 20);
145
+ // },
146
+ // })
147
+ // ).current
148
+
149
+ const handleMomentClick = () => {
150
+ if (isPreorderEnabled) {
151
+ navigation.navigate('MomentOption')
152
+ }
153
+ }
154
+
155
+ const configTypes =
156
+ configs?.order_types_allowed?.value
157
+ .split('|')
158
+ .map((value: any) => Number(value)) || [];
159
+
160
+ const handleScroll = ({ nativeEvent }: any) => {
161
+ const y = nativeEvent.contentOffset.y;
162
+ const height = nativeEvent.contentSize.height;
163
+ const hasMore = !(
164
+ paginationProps.totalPages === paginationProps.currentPage
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
+ useEffect(() => {
255
+ setIsOpenCities(false)
256
+ }, [orderState?.options?.city_id])
257
+
258
+ if (logosLayout) {
259
+ return (
260
+ <BusinessLogosContainer horizontal>
261
+ {businessesList?.loading ? (
262
+ <Placeholder Animation={Fade}>
263
+ {[...Array(10).keys()].map(item => (
264
+ <PlaceholderLine key={item} width={56} height={56} />
265
+ ))}
266
+ </Placeholder>
267
+ ) : (
268
+ <>
269
+ {businessesList.businesses
270
+ ?.filter(business => business?.slug !== actualSlug && business?.open)
271
+ ?.map(business => (
272
+ <TouchableOpacity
273
+ key={business?.id}
274
+ onPress={() => handleBusinessClick && handleBusinessClick(business)}
275
+ >
276
+ <FastImage
277
+ style={{ width: 56, height: 56, marginRight: 20, borderRadius: 7.6 }}
278
+ source={{
279
+ uri: business?.logo,
280
+ priority: FastImage.priority.normal,
281
+ }}
282
+ resizeMode={FastImage.resizeMode.cover}
283
+ />
284
+ </TouchableOpacity>
285
+ ))}
286
+ </>
287
+ )}
288
+ </BusinessLogosContainer>
289
+ )
290
+ }
291
+
292
+ return (
293
+ <ScrollView style={styles.container} onScroll={(e) => handleScroll(e)} showsVerticalScrollIndicator={false}
294
+ refreshControl={
295
+ <RefreshControl
296
+ refreshing={refreshing}
297
+ onRefresh={() => handleOnRefresh()}
298
+ />
299
+ }
300
+ >
301
+ <View style={{ height: isFarAway ? 150 : 100, marginTop: Platform.OS == 'ios' ? 0 : 50 }}>
302
+ <Search>
303
+ <AddressInput
304
+ onPress={() =>
305
+ auth
306
+ ? navigation.navigate('AddressList', { isFromBusinesses: true })
307
+ : navigation.navigate('AddressForm', {
308
+ address: orderState.options?.address,
309
+ isFromBusinesses: true,
310
+ isGuestUser: isGuestUser
311
+ })
312
+ }>
313
+ <AddressInputContainer>
314
+ <OIcon
315
+ src={theme.images.general.pin}
316
+ color={theme.colors.disabled}
317
+ width={16}
318
+ style={{ marginRight: 10 }}
319
+ />
320
+ <OText size={12} numberOfLines={1}>
321
+ {orderState?.options?.address?.address}
322
+ </OText>
323
+ <OIcon
324
+ src={theme.images.general.arrow_down}
325
+ width={10}
326
+ style={{ marginStart: 8 }}
327
+ />
328
+ </AddressInputContainer>
329
+ </AddressInput>
330
+ </Search>
331
+ {isFarAway && (
332
+ <FarAwayMessage style={styles.farAwayMsg}>
333
+ <Ionicons name='md-warning-outline' style={styles.iconStyle} />
334
+ <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textNormal}>{t('YOU_ARE_FAR_FROM_ADDRESS', 'You are far from this address')}</OText>
335
+ </FarAwayMessage>
336
+ )}
337
+
338
+ <OrderControlContainer>
339
+ <View style={styles.wrapperOrderOptions}>
340
+ {isPreOrderSetting && (
341
+ <WrapMomentOption
342
+ onPress={() => handleMomentClick()}>
343
+ <OText
344
+ size={12}
345
+ numberOfLines={1}
346
+ ellipsizeMode="tail"
347
+ color={theme.colors.textSecondary}>
348
+ {orderState.options?.moment
349
+ ? parseDate(orderState.options?.moment, { outputFormat: configs?.dates_moment_format?.value })
350
+ : t('ASAP_ABBREVIATION', 'ASAP')}
351
+ </OText>
352
+ {isPreorderEnabled && (
353
+ <OIcon
354
+ src={theme.images.general.arrow_down}
355
+ width={10}
356
+ style={{ marginStart: 8 }}
357
+ />
358
+ )}
359
+ </WrapMomentOption>
360
+ )}
361
+ <WrapMomentOption onPress={() => navigation.navigate('OrderTypes', { configTypes: configTypes, setOrderTypeValue })}>
362
+ <OText size={12} numberOfLines={1} ellipsizeMode={'tail'} color={theme.colors.textSecondary}>{t(getTypesText(orderTypeValue || orderState?.options?.type || 1), 'Delivery')}</OText>
363
+ <OIcon
364
+ src={theme.images.general.arrow_down}
365
+ width={10}
366
+ style={{ marginStart: 8 }}
367
+ />
368
+ </WrapMomentOption>
369
+ </View>
370
+ </OrderControlContainer>
371
+ </View>
372
+ <HeaderWrapper
373
+ source={theme.images.backgrounds.business_list_header}
374
+ style={{ paddingTop: top + 20 }}
375
+ resizeMode='stretch'
376
+ >
377
+ {!auth && (
378
+ <TouchableOpacity onPress={() => navigation?.canGoBack() && navigation.goBack()} style={{ position: 'absolute', marginStart: 40, paddingVertical: 20 }}>
379
+ <OIcon src={theme.images.general.arrow_left} width={20} style={{ tintColor: theme.colors.white }} />
380
+ </TouchableOpacity>
381
+ )}
382
+ </HeaderWrapper>
383
+ {!businessId && (
384
+ <SearchBar
385
+ onSearch={handleChangeSearch}
386
+ searchValue={searchValue}
387
+ lazyLoad
388
+ hideIcon
389
+ isCancelXButtonShow={!!searchValue}
390
+ onCancel={() => handleChangeSearch('')}
391
+ placeholder={t('SEARCH', 'Search')}
392
+ height={50}
393
+ isDisabled={!businessTypes || configs?.advanced_business_search_enabled?.value === '1'}
394
+ inputContainerStyles={styles.inputContainerStyles}
395
+ containerStyles={{
396
+ marginHorizontal: 40,
397
+ marginTop: 20
398
+ }}
399
+ inputStyle={{ ...styles.searchInput, ...Platform.OS === 'ios' ? { paddingBottom: 6 } : { paddingBottom: 4 } }}
400
+ onPress={() => { configs?.advanced_business_search_enabled?.value === '1' && navigation.navigate('BusinessSearch', { businessTypes }) }}
401
+ onSubmitEditing={() => { configs?.advanced_business_search_enabled?.value === '1' && navigation.navigate('BusinessSearch', { businessTypes, defaultTerm: searchValue }) }}
402
+ />
403
+ )}
404
+ <OrderProgressWrapper>
405
+ <OrderProgress
406
+ {...props}
407
+ isFocused={isFocused}
408
+ />
409
+ </OrderProgressWrapper>
410
+
411
+ {
412
+ !businessId && !props.franchiseId && featuredBusiness && featuredBusiness.length > 0 && (
413
+ <FeaturedWrapper>
414
+ <OText size={16} style={{ marginLeft: 40 }} weight={Platform.OS === 'ios' ? '600' : 'bold'}>{t('BUSINESS_FEATURE', 'Featured business')}</OText>
415
+ <ScrollView
416
+ showsHorizontalScrollIndicator={false}
417
+ nestedScrollEnabled
418
+ horizontal contentContainerStyle={{ paddingHorizontal: 40 }}>
419
+ {featuredBusiness.map((bAry: any, idx) => (
420
+ <View key={'f-listing_' + idx}>
421
+ <BusinessFeaturedController
422
+ business={bAry[0]}
423
+ isBusinessOpen={bAry[0]?.open}
424
+ handleCustomClick={handleBusinessClick}
425
+ orderType={orderState?.options?.type}
426
+ />
427
+ {bAry.length > 1 && (
428
+ <BusinessFeaturedController
429
+ business={bAry[1]}
430
+ isBusinessOpen={bAry[1]?.open}
431
+ handleCustomClick={handleBusinessClick}
432
+ orderType={orderState?.options?.type}
433
+ />
434
+ )}
435
+ </View>
436
+ ))}
437
+ </ScrollView>
438
+ </FeaturedWrapper>
439
+ )
440
+ }
441
+ <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
442
+ {
443
+ !businessId && !props.franchiseId && (
444
+ <HighestRatedBusinesses
445
+ onBusinessClick={handleBusinessClick}
446
+ navigation={navigation}
447
+ favoriteIds={favoriteIds}
448
+ setFavoriteIds={setFavoriteIds}
449
+ />
450
+ )
451
+ }
452
+ <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
453
+ <ListWrapper>
454
+ {!businessId && (
455
+ <BusinessTypeFilter
456
+ images={props.images}
457
+ businessTypes={props.businessTypes}
458
+ defaultBusinessType={props.defaultBusinessType}
459
+ handleChangeBusinessType={handleChangeBusinessType}
460
+ setBusinessTypes={setBusinessTypes}
461
+ />
462
+ )}
463
+ {!businessesList.loading && businessesList.businesses.length === 0 && (
464
+ <NotFoundSource
465
+ content={t(
466
+ 'NOT_FOUND_BUSINESSES',
467
+ 'No businesses to delivery / pick up at this address, please change filters or change address.',
468
+ )}
469
+ />
470
+ )}
471
+ {businessesList.businesses?.map(
472
+ (business: any, i: number) => (
473
+ <BusinessController
474
+ key={`${business.id}_` + i}
475
+ enableIntersection
476
+ business={business}
477
+ isBusinessOpen={business.open}
478
+ handleCustomClick={handleBusinessClick}
479
+ orderType={orderState?.options?.type}
480
+ navigation={navigation}
481
+ businessHeader={business?.header}
482
+ businessFeatured={business?.featured}
483
+ businessLogo={business?.logo}
484
+ businessReviews={business?.reviews}
485
+ businessDeliveryPrice={business?.delivery_price}
486
+ businessDeliveryTime={business?.delivery_time}
487
+ businessPickupTime={business?.pickup_time}
488
+ businessDistance={business?.distance}
489
+ handleUpdateBusinessList={handleUpdateBusinessList}
490
+ favoriteIds={favoriteIds}
491
+ setFavoriteIds={setFavoriteIds}
492
+ />
493
+ )
494
+ )}
495
+ {businessesList.loading && (
496
+ <>
497
+ {[
498
+ ...Array(
499
+ paginationProps.nextPageItems
500
+ ? paginationProps.nextPageItems
501
+ : 8,
502
+ ).keys(),
503
+ ].map((item, i) => (
504
+ <Placeholder
505
+ Animation={Fade}
506
+ key={i}
507
+ style={{ marginBottom: 20 }}>
508
+ <View style={{ width: '100%' }}>
509
+ <PlaceholderLine
510
+ height={200}
511
+ style={{ marginBottom: 20, borderRadius: 25 }}
512
+ />
513
+ <View style={{ paddingHorizontal: 10 }}>
514
+ <View
515
+ style={{
516
+ flexDirection: 'row',
517
+ justifyContent: 'space-between',
518
+ }}>
519
+ <PlaceholderLine
520
+ height={25}
521
+ width={40}
522
+ style={{ marginBottom: 10 }}
523
+ />
524
+ <PlaceholderLine
525
+ height={25}
526
+ width={20}
527
+ style={{ marginBottom: 10 }}
528
+ />
529
+ </View>
530
+ <PlaceholderLine
531
+ height={20}
532
+ width={30}
533
+ style={{ marginBottom: 10 }}
534
+ />
535
+ <PlaceholderLine
536
+ height={20}
537
+ width={80}
538
+ style={{ marginBottom: 10 }}
539
+ />
540
+ </View>
541
+ </View>
542
+ </Placeholder>
543
+ ))}
544
+ </>
545
+ )}
546
+ </ListWrapper>
547
+ </ScrollView>
548
+ );
549
+ };
550
+
551
+ export const BusinessesListing = (props: BusinessesListingParams) => {
552
+ const BusinessesListingProps = {
553
+ ...props,
554
+ isForceSearch: Platform.OS === 'ios',
555
+ UIComponent: BusinessesListingUI,
556
+ };
557
+
558
+ return <BusinessesListingController {...BusinessesListingProps} />;
559
+ };
@@ -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
+ `