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