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