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