ordering-ui-react-native 0.16.9 → 0.16.10-release

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