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