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