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