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