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