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