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