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