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