ordering-ui-react-native 0.14.35 → 0.14.37-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 +2 -2
- package/src/components/BusinessItemAccordion/index.tsx +2 -2
- package/src/components/BusinessProductsListing/index.tsx +10 -26
- package/src/components/Cart/index.tsx +136 -62
- package/src/components/Cart/styles.tsx +7 -0
- package/src/components/Checkout/index.tsx +32 -168
- package/src/components/OrderDetails/index.tsx +102 -34
- package/src/components/OrderDetails/styles.tsx +7 -0
- package/src/components/OrderSummary/index.tsx +142 -58
- package/src/components/OrderSummary/styles.tsx +10 -2
- package/src/components/PaymentOptions/index.tsx +3 -1
- package/src/components/PaymentOptionsWebView/index.tsx +150 -0
- package/src/components/ProductForm/index.tsx +6 -8
- package/src/components/SingleProductCard/index.tsx +1 -1
- package/src/components/StripeElementsForm/index.tsx +28 -13
- package/src/components/TaxInformation/index.tsx +58 -26
- package/src/components/UpsellingProducts/index.tsx +13 -31
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/index.tsx +2 -0
- package/src/navigators/HomeNavigator.tsx +6 -0
- package/src/pages/ProductDetails.tsx +55 -0
- package/src/types/index.tsx +2 -0
- package/src/types/react-native-color-matrix-image-filters/index.d.ts +1 -0
- package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
- package/themes/kiosk/src/components/Cart/index.tsx +14 -21
- package/themes/kiosk/src/components/CartItem/index.tsx +9 -7
- package/themes/kiosk/src/components/CustomerName/index.tsx +2 -1
- package/themes/kiosk/src/components/Intro/index.tsx +4 -4
- package/themes/kiosk/src/components/OptionCard/index.tsx +11 -6
- package/themes/kiosk/src/components/PaymentOptions/index.tsx +46 -44
- package/themes/original/index.tsx +4 -0
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -9
- package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -2
- package/themes/original/src/components/BusinessPreorder/index.tsx +37 -35
- package/themes/original/src/components/BusinessProductsListing/UpsellingRedirect.tsx +35 -0
- package/themes/original/src/components/BusinessProductsListing/index.tsx +22 -49
- package/themes/original/src/components/BusinessesListing/index.tsx +100 -75
- package/themes/original/src/components/Cart/index.tsx +129 -52
- package/themes/original/src/components/Cart/styles.tsx +8 -1
- package/themes/original/src/components/Checkout/index.tsx +38 -2
- package/themes/original/src/components/Help/index.tsx +1 -1
- package/themes/original/src/components/Home/index.tsx +5 -3
- package/themes/original/src/components/MessageListing/index.tsx +4 -2
- package/themes/original/src/components/OrderDetails/index.tsx +117 -43
- package/themes/original/src/components/OrderDetails/styles.tsx +8 -1
- package/themes/original/src/components/OrderSummary/index.tsx +141 -51
- package/themes/original/src/components/OrderSummary/styles.tsx +7 -0
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
- package/themes/original/src/components/PaymentOptions/index.tsx +8 -2
- package/themes/original/src/components/ProductForm/index.tsx +67 -77
- package/themes/original/src/components/ProductForm/styles.tsx +9 -2
- package/themes/original/src/components/SingleProductCard/index.tsx +21 -11
- package/themes/original/src/components/SingleProductCard/styles.tsx +4 -0
- package/themes/original/src/components/StripeElementsForm/index.tsx +28 -13
- package/themes/original/src/components/TaxInformation/index.tsx +59 -27
- package/themes/original/src/components/UpsellingProducts/index.tsx +90 -84
- package/themes/original/src/types/index.tsx +6 -0
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
ScrollView,
|
|
8
8
|
Platform,
|
|
9
9
|
TouchableOpacity,
|
|
10
|
+
RefreshControl
|
|
10
11
|
} from 'react-native';
|
|
11
12
|
import {
|
|
12
13
|
BusinessList as BusinessesListingController,
|
|
@@ -57,11 +58,12 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
57
58
|
handleBusinessClick,
|
|
58
59
|
paginationProps,
|
|
59
60
|
handleChangeSearch,
|
|
60
|
-
|
|
61
|
+
businessId
|
|
61
62
|
} = props;
|
|
62
63
|
|
|
63
64
|
const theme = useTheme();
|
|
64
65
|
const isFocused = useIsFocused();
|
|
66
|
+
const [refreshing] = useState(false);
|
|
65
67
|
|
|
66
68
|
const styles = StyleSheet.create({
|
|
67
69
|
container: {
|
|
@@ -142,15 +144,15 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
142
144
|
};
|
|
143
145
|
|
|
144
146
|
const getDistance = (lat1: any, lon1: any, lat2: any, lon2: any) => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
147
|
+
const R = 6371 // km
|
|
148
|
+
const dLat = convertToRadian(lat2 - lat1)
|
|
149
|
+
const dLon = convertToRadian(lon2 - lon1)
|
|
150
|
+
const curLat1 = convertToRadian(lat1)
|
|
151
|
+
const curLat2 = convertToRadian(lat2)
|
|
152
|
+
const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(curLat1) * Math.cos(curLat2)
|
|
153
|
+
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
|
|
154
|
+
return R * c
|
|
155
|
+
}
|
|
154
156
|
|
|
155
157
|
useEffect(() => {
|
|
156
158
|
if (businessesList.businesses.length > 0) {
|
|
@@ -162,6 +164,7 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
162
164
|
setFeaturedBusinesses(ary);
|
|
163
165
|
}
|
|
164
166
|
}, [businessesList.businesses]);
|
|
167
|
+
|
|
165
168
|
// const resetInactivityTimeout = () => {
|
|
166
169
|
// clearTimeout(timerId.current)
|
|
167
170
|
// timerId.current = setInterval(() => {
|
|
@@ -173,21 +176,37 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
173
176
|
// resetInactivityTimeout()
|
|
174
177
|
// }, [])
|
|
175
178
|
|
|
179
|
+
const handleOnRefresh = () => {
|
|
180
|
+
const hasMore = !(
|
|
181
|
+
paginationProps.totalPages === paginationProps.currentPage
|
|
182
|
+
);
|
|
183
|
+
if (!businessesList.loading && hasMore) {
|
|
184
|
+
getBusinesses();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
176
188
|
useEffect(() => {
|
|
177
189
|
Geolocation.getCurrentPosition((pos) => {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
190
|
+
const crd = pos.coords
|
|
191
|
+
const distance = getDistance(crd.latitude, crd.longitude, orderState?.options?.address?.location?.lat, orderState?.options?.address?.location?.lng)
|
|
192
|
+
if (distance > 20) setIsFarAway(true)
|
|
181
193
|
else setIsFarAway(false)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
194
|
+
}, (err) => {
|
|
195
|
+
console.log(`ERROR(${err.code}): ${err.message}`)
|
|
196
|
+
}, {
|
|
197
|
+
enableHighAccuracy: true, timeout: 15000, maximumAge: 10000
|
|
198
|
+
})
|
|
199
|
+
}, [orderState?.options?.address?.location])
|
|
188
200
|
|
|
189
201
|
return (
|
|
190
|
-
<ScrollView style={styles.container} onScroll={(e) => handleScroll(e)} showsVerticalScrollIndicator={false}
|
|
202
|
+
<ScrollView style={styles.container} onScroll={(e) => handleScroll(e)} showsVerticalScrollIndicator={false}
|
|
203
|
+
refreshControl={
|
|
204
|
+
<RefreshControl
|
|
205
|
+
refreshing={refreshing}
|
|
206
|
+
onRefresh={() => handleOnRefresh()}
|
|
207
|
+
/>
|
|
208
|
+
}
|
|
209
|
+
>
|
|
191
210
|
<HeaderWrapper
|
|
192
211
|
source={theme.images.backgrounds.business_list_header}
|
|
193
212
|
style={{ paddingTop: top + 20 }}>
|
|
@@ -257,72 +276,78 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
|
|
|
257
276
|
/>
|
|
258
277
|
</WrapMomentOption>
|
|
259
278
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
279
|
+
{!businessId && (
|
|
280
|
+
<SearchBar
|
|
281
|
+
onSearch={handleChangeSearch}
|
|
282
|
+
searchValue={searchValue}
|
|
283
|
+
lazyLoad
|
|
284
|
+
isCancelXButtonShow={!!searchValue}
|
|
285
|
+
borderStyle={styles.borderStyle}
|
|
286
|
+
onCancel={() => handleChangeSearch('')}
|
|
287
|
+
placeholder={t('SEARCH', 'Search')}
|
|
288
|
+
height={26}
|
|
289
|
+
inputStyle={{ ...styles.searchInput, ...Platform.OS === 'ios' ? {} : { paddingBottom: 4 } }}
|
|
290
|
+
/>
|
|
291
|
+
)}
|
|
273
292
|
|
|
274
293
|
</View>
|
|
275
294
|
</OrderControlContainer>
|
|
276
295
|
</HeaderWrapper>
|
|
277
|
-
{
|
|
278
|
-
|
|
279
|
-
<
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
handleCustomClick={handleBusinessClick}
|
|
297
|
-
orderType={orderState?.options?.type}
|
|
298
|
-
/>
|
|
299
|
-
{bAry.length > 1 && (
|
|
296
|
+
{
|
|
297
|
+
isFocused && (
|
|
298
|
+
<OrderProgressWrapper>
|
|
299
|
+
<OrderProgress
|
|
300
|
+
{...props}
|
|
301
|
+
/>
|
|
302
|
+
</OrderProgressWrapper>
|
|
303
|
+
)
|
|
304
|
+
}
|
|
305
|
+
{
|
|
306
|
+
!businessId && !props.franchiseId && featuredBusiness && featuredBusiness.length > 0 && (
|
|
307
|
+
<FeaturedWrapper>
|
|
308
|
+
<OText size={16} style={{ marginLeft: 40 }} weight={Platform.OS === 'ios' ? '600' : 'bold'}>{t('FEATURED_BUSINESS', 'Featured business')}</OText>
|
|
309
|
+
<ScrollView
|
|
310
|
+
showsHorizontalScrollIndicator={false}
|
|
311
|
+
nestedScrollEnabled
|
|
312
|
+
horizontal contentContainerStyle={{ paddingHorizontal: 40 }}>
|
|
313
|
+
{featuredBusiness.map((bAry: any, idx) => (
|
|
314
|
+
<View key={'f-listing_' + idx}>
|
|
300
315
|
<BusinessFeaturedController
|
|
301
|
-
key={bAry[
|
|
302
|
-
business={bAry[
|
|
316
|
+
key={bAry[0].id}
|
|
317
|
+
business={bAry[0]}
|
|
303
318
|
handleCustomClick={handleBusinessClick}
|
|
304
319
|
orderType={orderState?.options?.type}
|
|
305
320
|
/>
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
321
|
+
{bAry.length > 1 && (
|
|
322
|
+
<BusinessFeaturedController
|
|
323
|
+
key={bAry[1].id}
|
|
324
|
+
business={bAry[1]}
|
|
325
|
+
handleCustomClick={handleBusinessClick}
|
|
326
|
+
orderType={orderState?.options?.type}
|
|
327
|
+
/>
|
|
328
|
+
)}
|
|
329
|
+
</View>
|
|
330
|
+
))}
|
|
331
|
+
</ScrollView>
|
|
332
|
+
</FeaturedWrapper>
|
|
333
|
+
)
|
|
334
|
+
}
|
|
312
335
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
336
|
+
{
|
|
337
|
+
!businessId && !props.franchiseId && (
|
|
338
|
+
<HighestRatedBusinesses onBusinessClick={handleBusinessClick} navigation={navigation} />
|
|
339
|
+
)
|
|
340
|
+
}
|
|
316
341
|
<View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100 }} />
|
|
317
342
|
<ListWrapper>
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
343
|
+
{!businessId && (
|
|
344
|
+
<BusinessTypeFilter
|
|
345
|
+
images={props.images}
|
|
346
|
+
businessTypes={props.businessTypes}
|
|
347
|
+
defaultBusinessType={props.defaultBusinessType}
|
|
348
|
+
handleChangeBusinessType={handleChangeBusinessType}
|
|
349
|
+
/>
|
|
350
|
+
)}
|
|
326
351
|
{!businessesList.loading && businessesList.businesses.length === 0 && (
|
|
327
352
|
<NotFoundSource
|
|
328
353
|
content={t(
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
useValidationFields,
|
|
9
9
|
} from 'ordering-components/native';
|
|
10
10
|
import { useTheme } from 'styled-components/native';
|
|
11
|
-
import { CContainer, CheckoutAction } from './styles';
|
|
11
|
+
import { CContainer, CheckoutAction, Divider } from './styles';
|
|
12
12
|
|
|
13
13
|
import { OSBill, OSTable, OSCoupon, OSTotal, OSRow } from '../OrderSummary/styles';
|
|
14
14
|
|
|
@@ -17,13 +17,13 @@ import { BusinessItemAccordion } from '../BusinessItemAccordion';
|
|
|
17
17
|
import { CouponControl } from '../CouponControl';
|
|
18
18
|
|
|
19
19
|
import { OButton, OInput, OModal, OText } from '../shared';
|
|
20
|
-
import { ProductForm } from '../ProductForm';
|
|
21
20
|
import { UpsellingProducts } from '../UpsellingProducts';
|
|
22
21
|
import { verifyDecimals } from '../../utils';
|
|
23
22
|
import { ActivityIndicator, TouchableOpacity, View } from 'react-native';
|
|
24
23
|
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
25
24
|
import { TaxInformation } from '../TaxInformation';
|
|
26
25
|
import { CartStoresListing } from '../CartStoresListing';
|
|
26
|
+
import { OAlert } from '../../../../../src/components/shared'
|
|
27
27
|
|
|
28
28
|
const CartUI = (props: any) => {
|
|
29
29
|
const {
|
|
@@ -35,10 +35,10 @@ const CartUI = (props: any) => {
|
|
|
35
35
|
removeProduct,
|
|
36
36
|
handleCartOpen,
|
|
37
37
|
setIsCartsLoading,
|
|
38
|
-
hideUpselling,
|
|
39
38
|
handleChangeComment,
|
|
40
|
-
commentState
|
|
41
|
-
|
|
39
|
+
commentState,
|
|
40
|
+
onNavigationRedirect,
|
|
41
|
+
handleRemoveOfferClick
|
|
42
42
|
} = props
|
|
43
43
|
|
|
44
44
|
const theme = useTheme();
|
|
@@ -49,12 +49,11 @@ const CartUI = (props: any) => {
|
|
|
49
49
|
const [{ parsePrice, parseNumber, parseDate }] = useUtils()
|
|
50
50
|
const [validationFields] = useValidationFields()
|
|
51
51
|
|
|
52
|
-
const [openProduct, setModalIsOpen] = useState(false)
|
|
53
|
-
const [curProduct, setCurProduct] = useState<any>(null)
|
|
54
52
|
const [openUpselling, setOpenUpselling] = useState(false)
|
|
55
53
|
const [openChangeStore, setOpenChangeStore] = useState(false)
|
|
56
54
|
const [canOpenUpselling, setCanOpenUpselling] = useState(false)
|
|
57
|
-
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
55
|
+
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null, type: '' })
|
|
56
|
+
const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
|
|
58
57
|
|
|
59
58
|
const isCartPending = cart?.status === 2
|
|
60
59
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
|
|
@@ -71,14 +70,14 @@ const CartUI = (props: any) => {
|
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
const handleEditProduct = (product: any) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
73
|
+
onNavigationRedirect('ProductDetails', {
|
|
74
|
+
businessId,
|
|
75
|
+
isCartProduct: true,
|
|
76
|
+
productCart: product,
|
|
77
|
+
businessSlug: cart?.business?.slug,
|
|
78
|
+
categoryId: product?.category_id,
|
|
79
|
+
productId: product?.id,
|
|
80
|
+
})
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
const handleClearProducts = async () => {
|
|
@@ -113,6 +112,22 @@ const CartUI = (props: any) => {
|
|
|
113
112
|
}
|
|
114
113
|
}
|
|
115
114
|
|
|
115
|
+
const getIncludedTaxesDiscounts = () => {
|
|
116
|
+
return cart?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const onRemoveOffer = (id: number) => {
|
|
120
|
+
setConfirm({
|
|
121
|
+
open: true,
|
|
122
|
+
content: [t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')],
|
|
123
|
+
title: t('OFFER', 'Offer'),
|
|
124
|
+
handleOnAccept: () => {
|
|
125
|
+
setConfirm({ ...confirm, open: false })
|
|
126
|
+
handleRemoveOfferClick(id)
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
|
|
116
131
|
const walletName: any = {
|
|
117
132
|
cash: {
|
|
118
133
|
name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
|
|
@@ -170,7 +185,7 @@ const CartUI = (props: any) => {
|
|
|
170
185
|
{parsePrice(cart?.subtotal + getIncludedTaxes())}
|
|
171
186
|
</OText>
|
|
172
187
|
</OSTable>
|
|
173
|
-
{cart?.discount > 0 && cart?.total >= 0 && (
|
|
188
|
+
{cart?.discount > 0 && cart?.total >= 0 && cart?.offers?.length === 0 && (
|
|
174
189
|
<OSTable>
|
|
175
190
|
{cart?.discount_type === 1 ? (
|
|
176
191
|
<OText size={12} lineHeight={18}>
|
|
@@ -183,19 +198,51 @@ const CartUI = (props: any) => {
|
|
|
183
198
|
<OText size={12} lineHeight={18}>- {parsePrice(cart?.discount || 0)}</OText>
|
|
184
199
|
</OSTable>
|
|
185
200
|
)}
|
|
201
|
+
{
|
|
202
|
+
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
|
|
203
|
+
<OSTable key={offer.id}>
|
|
204
|
+
<OSRow>
|
|
205
|
+
<OText size={12} lineHeight={18}>{offer.name}</OText>
|
|
206
|
+
{offer.rate_type === 1 && (
|
|
207
|
+
<OText size={12} lineHeight={18}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
208
|
+
)}
|
|
209
|
+
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
|
|
210
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
211
|
+
</TouchableOpacity>
|
|
212
|
+
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
|
|
213
|
+
<AntIcon name='closecircle' size={18} color={theme.colors.primary} />
|
|
214
|
+
</TouchableOpacity>
|
|
215
|
+
</OSRow>
|
|
216
|
+
<OText size={12} lineHeight={18}>
|
|
217
|
+
- {parsePrice(offer?.summary?.discount)}
|
|
218
|
+
</OText>
|
|
219
|
+
</OSTable>
|
|
220
|
+
))
|
|
221
|
+
}
|
|
222
|
+
<Divider />
|
|
223
|
+
{cart?.subtotal_with_discount > 0 && cart?.discount > 0 && cart?.total >= 0 && (
|
|
224
|
+
<OSTable>
|
|
225
|
+
<OText size={12} lineHeight={18} numberOfLines={1}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
|
|
226
|
+
{cart?.business?.tax_type === 1 ? (
|
|
227
|
+
<OText size={12} lineHeight={18}>{parsePrice(cart?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0)}</OText>
|
|
228
|
+
) : (
|
|
229
|
+
<OText size={12} lineHeight={18}>{parsePrice(cart?.subtotal_with_discount ?? 0)}</OText>
|
|
230
|
+
)}
|
|
231
|
+
</OSTable>
|
|
232
|
+
)}
|
|
186
233
|
{
|
|
187
234
|
cart.taxes?.length > 0 && cart.taxes.filter((tax: any) => tax.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
188
235
|
<OSTable key={tax.id}>
|
|
189
236
|
<OSRow>
|
|
190
|
-
<OText numberOfLines={1} >
|
|
237
|
+
<OText size={12} lineHeight={18} numberOfLines={1} >
|
|
191
238
|
{tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
192
239
|
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
193
240
|
</OText>
|
|
194
|
-
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
|
|
241
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax, type: 'tax' })} >
|
|
195
242
|
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
196
243
|
</TouchableOpacity>
|
|
197
244
|
</OSRow>
|
|
198
|
-
<OText>{parsePrice(tax?.summary?.tax
|
|
245
|
+
<OText size={12} lineHeight={18}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
|
|
199
246
|
</OSTable>
|
|
200
247
|
))
|
|
201
248
|
}
|
|
@@ -203,33 +250,66 @@ const CartUI = (props: any) => {
|
|
|
203
250
|
cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any) => (
|
|
204
251
|
<OSTable key={fee?.id}>
|
|
205
252
|
<OSRow>
|
|
206
|
-
<OText
|
|
253
|
+
<OText size={12} lineHeight={18} numberOfLines={1}>
|
|
207
254
|
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
208
255
|
({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
|
|
209
256
|
</OText>
|
|
210
|
-
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
|
|
257
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
|
|
211
258
|
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
212
259
|
</TouchableOpacity>
|
|
213
260
|
</OSRow>
|
|
214
|
-
<OText>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage
|
|
261
|
+
<OText size={12} lineHeight={18}>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
|
|
262
|
+
</OSTable>
|
|
263
|
+
))
|
|
264
|
+
}
|
|
265
|
+
{
|
|
266
|
+
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
|
|
267
|
+
<OSTable key={offer.id}>
|
|
268
|
+
<OSRow>
|
|
269
|
+
<OText size={12} lineHeight={18}>{offer.name}</OText>
|
|
270
|
+
{offer.rate_type === 1 && (
|
|
271
|
+
<OText size={12} lineHeight={18}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
272
|
+
)}
|
|
273
|
+
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
|
|
274
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
275
|
+
</TouchableOpacity>
|
|
276
|
+
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
|
|
277
|
+
<AntIcon name='closecircle' size={18} color={theme.colors.primary} />
|
|
278
|
+
</TouchableOpacity>
|
|
279
|
+
</OSRow>
|
|
280
|
+
<OText size={12} lineHeight={18}>
|
|
281
|
+
- {parsePrice(offer?.summary?.discount)}
|
|
282
|
+
</OText>
|
|
215
283
|
</OSTable>
|
|
216
284
|
))
|
|
217
285
|
}
|
|
218
|
-
{cart?.service_fee > 0 && !cart?.fees?.length && (
|
|
219
|
-
<OSTable>
|
|
220
|
-
<OText size={12} lineHeight={18}>
|
|
221
|
-
{t('SERVICE_FEE', 'Service Fee')}
|
|
222
|
-
{`(${verifyDecimals(cart?.business?.service_fee, parseNumber)}%)`}
|
|
223
|
-
</OText>
|
|
224
|
-
<OText size={12} lineHeight={18}>{parsePrice(cart?.service_fee)}</OText>
|
|
225
|
-
</OSTable>
|
|
226
|
-
)}
|
|
227
286
|
{orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
|
|
228
287
|
<OSTable>
|
|
229
288
|
<OText size={12} lineHeight={18}>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
|
|
230
289
|
<OText size={12} lineHeight={18}>{parsePrice(cart?.delivery_price)}</OText>
|
|
231
290
|
</OSTable>
|
|
232
291
|
)}
|
|
292
|
+
{
|
|
293
|
+
cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
|
|
294
|
+
<OSTable key={offer.id}>
|
|
295
|
+
<OSRow>
|
|
296
|
+
<OText size={12} lineHeight={18}>{offer.name}</OText>
|
|
297
|
+
{offer.rate_type === 1 && (
|
|
298
|
+
<OText size={12} lineHeight={18}>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
299
|
+
)}
|
|
300
|
+
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
|
|
301
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
302
|
+
</TouchableOpacity>
|
|
303
|
+
<TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
|
|
304
|
+
<AntIcon name='closecircle' size={18} color={theme.colors.primary} />
|
|
305
|
+
</TouchableOpacity>
|
|
306
|
+
</OSRow>
|
|
307
|
+
<OText size={12} lineHeight={18}>
|
|
308
|
+
- {parsePrice(offer?.summary?.discount)}
|
|
309
|
+
</OText>
|
|
310
|
+
</OSTable>
|
|
311
|
+
))
|
|
312
|
+
}
|
|
233
313
|
{cart?.driver_tip > 0 && (
|
|
234
314
|
<OSTable>
|
|
235
315
|
<OText size={12} lineHeight={18}>
|
|
@@ -269,7 +349,7 @@ const CartUI = (props: any) => {
|
|
|
269
349
|
{t('TOTAL', 'Total')}
|
|
270
350
|
</OText>
|
|
271
351
|
<OText size={14} lineHeight={21} weight={'600'}>
|
|
272
|
-
{parsePrice(cart?.
|
|
352
|
+
{parsePrice(cart?.total >= 0 ? cart?.total : 0)}
|
|
273
353
|
</OText>
|
|
274
354
|
</OSTable>
|
|
275
355
|
</OSTotal>
|
|
@@ -329,23 +409,6 @@ const CartUI = (props: any) => {
|
|
|
329
409
|
</CheckoutAction>
|
|
330
410
|
)}
|
|
331
411
|
</BusinessItemAccordion>
|
|
332
|
-
<OModal
|
|
333
|
-
open={openProduct}
|
|
334
|
-
entireModal
|
|
335
|
-
customClose
|
|
336
|
-
onClose={() => setModalIsOpen(false)}
|
|
337
|
-
>
|
|
338
|
-
<ProductForm
|
|
339
|
-
isCartProduct
|
|
340
|
-
productCart={curProduct}
|
|
341
|
-
businessSlug={cart?.business?.slug}
|
|
342
|
-
businessId={businessId}
|
|
343
|
-
categoryId={curProduct?.category_id}
|
|
344
|
-
productId={curProduct?.id}
|
|
345
|
-
onSave={handlerProductAction}
|
|
346
|
-
onClose={() => setModalIsOpen(false)}
|
|
347
|
-
/>
|
|
348
|
-
</OModal>
|
|
349
412
|
|
|
350
413
|
<OModal
|
|
351
414
|
open={openChangeStore && props.isFranchiseApp}
|
|
@@ -360,11 +423,25 @@ const CartUI = (props: any) => {
|
|
|
360
423
|
</OModal>
|
|
361
424
|
<OModal
|
|
362
425
|
open={openTaxModal.open}
|
|
363
|
-
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
426
|
+
onClose={() => setOpenTaxModal({ open: false, data: null, type: '' })}
|
|
364
427
|
entireModal
|
|
428
|
+
title={`${openTaxModal.data?.name ||
|
|
429
|
+
t('INHERIT_FROM_BUSINESS', 'Inherit from business')} ${openTaxModal.data?.rate_type !== 2 ? `(${typeof openTaxModal.data?.rate === 'number' ? `${openTaxModal.data?.rate}%` : `${parsePrice(openTaxModal.data?.fixed ?? 0)} + ${openTaxModal.data?.percentage}%`})` : ''} `}
|
|
365
430
|
>
|
|
366
|
-
<TaxInformation
|
|
431
|
+
<TaxInformation
|
|
432
|
+
type={openTaxModal.type}
|
|
433
|
+
data={openTaxModal.data}
|
|
434
|
+
products={cart?.products}
|
|
435
|
+
/>
|
|
367
436
|
</OModal>
|
|
437
|
+
<OAlert
|
|
438
|
+
open={confirm.open}
|
|
439
|
+
title={confirm.title}
|
|
440
|
+
content={confirm.content}
|
|
441
|
+
onAccept={confirm.handleOnAccept}
|
|
442
|
+
onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
|
|
443
|
+
onClose={() => setConfirm({ ...confirm, open: false, title: null })}
|
|
444
|
+
/>
|
|
368
445
|
</CContainer>
|
|
369
446
|
)
|
|
370
447
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import styled
|
|
1
|
+
import styled from 'styled-components/native';
|
|
2
2
|
|
|
3
3
|
export const CContainer = styled.View`
|
|
4
4
|
/* border-bottom: 1px solid #F0F0F0; */
|
|
@@ -26,3 +26,10 @@ export const CheckoutAction = styled.View`
|
|
|
26
26
|
margin-top: 10px;
|
|
27
27
|
margin-bottom: 10px;
|
|
28
28
|
`
|
|
29
|
+
|
|
30
|
+
export const Divider = styled.View`
|
|
31
|
+
border-color: #EAEAEA;
|
|
32
|
+
border-width: 1px;
|
|
33
|
+
margin-top: 5px;
|
|
34
|
+
margin-bottom: 10px;
|
|
35
|
+
`
|
|
@@ -49,6 +49,7 @@ import NavBar from '../NavBar';
|
|
|
49
49
|
import { OrderSummary } from '../OrderSummary';
|
|
50
50
|
import { getTypesText } from '../../utils';
|
|
51
51
|
import { CartStoresListing } from '../CartStoresListing';
|
|
52
|
+
import { PaymentOptionsWebView } from '../../../../../src/components/PaymentOptionsWebView';
|
|
52
53
|
|
|
53
54
|
const mapConfigs = {
|
|
54
55
|
mapZoom: 16,
|
|
@@ -83,6 +84,7 @@ const CheckoutUI = (props: any) => {
|
|
|
83
84
|
deliveryOptionSelected,
|
|
84
85
|
instructionsOptions,
|
|
85
86
|
handleChangeDeliveryOption,
|
|
87
|
+
currency
|
|
86
88
|
} = props
|
|
87
89
|
|
|
88
90
|
const theme = useTheme();
|
|
@@ -114,10 +116,11 @@ const CheckoutUI = (props: any) => {
|
|
|
114
116
|
|
|
115
117
|
const [, { showToast }] = useToast();
|
|
116
118
|
const [, t] = useLanguage();
|
|
117
|
-
const [{ user }] = useSession();
|
|
119
|
+
const [{ user, token }] = useSession();
|
|
120
|
+
const [ordering] = useApi()
|
|
118
121
|
const [{ configs }] = useConfig();
|
|
119
122
|
const [{ parsePrice, parseDate }] = useUtils();
|
|
120
|
-
const [{ options, carts, loading }] = useOrder();
|
|
123
|
+
const [{ options, carts, loading }, { confirmCart }] = useOrder();
|
|
121
124
|
const [validationFields] = useValidationFields();
|
|
122
125
|
|
|
123
126
|
const [errorCash, setErrorCash] = useState(false);
|
|
@@ -126,6 +129,10 @@ const CheckoutUI = (props: any) => {
|
|
|
126
129
|
const [phoneUpdate, setPhoneUpdate] = useState(false);
|
|
127
130
|
const [openChangeStore, setOpenChangeStore] = useState(false)
|
|
128
131
|
const [isDeliveryOptionModalVisible, setIsDeliveryOptionModalVisible] = useState(false)
|
|
132
|
+
const [showGateway, setShowGateway] = useState<any>({ closedByUsed: false, open: false });
|
|
133
|
+
const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
|
|
134
|
+
|
|
135
|
+
const isWalletEnabled = configs?.wallet_enabled?.value === '1' && (configs?.wallet_cash_enabled?.value === '1' || configs?.wallet_credit_point_enabled?.value === '1')
|
|
129
136
|
|
|
130
137
|
const driverTipsOptions = typeof configs?.driver_tip_options?.value === 'string'
|
|
131
138
|
? JSON.parse(configs?.driver_tip_options?.value) || []
|
|
@@ -154,6 +161,16 @@ const CheckoutUI = (props: any) => {
|
|
|
154
161
|
setIsUserDetailsEdit(true)
|
|
155
162
|
}
|
|
156
163
|
|
|
164
|
+
const handlePaymentMethodClick = (paymethod: any) => {
|
|
165
|
+
setShowGateway({ closedByUser: false, open: true })
|
|
166
|
+
setWebviewPaymethod(paymethod)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const onFailPaypal = async () => {
|
|
170
|
+
if (showGateway.closedByUser === true) {
|
|
171
|
+
await confirmCart(cart.uuid)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
157
174
|
const changeDeliveryOption = (option: any) => {
|
|
158
175
|
handleChangeDeliveryOption(option)
|
|
159
176
|
setIsDeliveryOptionModalVisible(false)
|
|
@@ -214,6 +231,10 @@ const CheckoutUI = (props: any) => {
|
|
|
214
231
|
}
|
|
215
232
|
}, [cart?.products])
|
|
216
233
|
|
|
234
|
+
useEffect(() => {
|
|
235
|
+
onFailPaypal()
|
|
236
|
+
}, [showGateway.closedByUser])
|
|
237
|
+
|
|
217
238
|
return (
|
|
218
239
|
<>
|
|
219
240
|
<Container noPadding>
|
|
@@ -501,6 +522,7 @@ const CheckoutUI = (props: any) => {
|
|
|
501
522
|
setErrorCash={setErrorCash}
|
|
502
523
|
onNavigationRedirect={onNavigationRedirect}
|
|
503
524
|
paySelected={paymethodSelected}
|
|
525
|
+
handlePaymentMethodClickCustom={handlePaymentMethodClick}
|
|
504
526
|
/>
|
|
505
527
|
</ChPaymethods>
|
|
506
528
|
</ChSection>
|
|
@@ -510,6 +532,7 @@ const CheckoutUI = (props: any) => {
|
|
|
510
532
|
<WalletPaymentOptionContainer>
|
|
511
533
|
<PaymentOptionWallet
|
|
512
534
|
cart={cart}
|
|
535
|
+
businessId={cart?.business_id}
|
|
513
536
|
/>
|
|
514
537
|
</WalletPaymentOptionContainer>
|
|
515
538
|
)}
|
|
@@ -546,6 +569,7 @@ const CheckoutUI = (props: any) => {
|
|
|
546
569
|
<OrderSummary
|
|
547
570
|
cart={cart}
|
|
548
571
|
isCartPending={cart?.status === 2}
|
|
572
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
549
573
|
/>
|
|
550
574
|
</>
|
|
551
575
|
)}
|
|
@@ -618,6 +642,18 @@ const CheckoutUI = (props: any) => {
|
|
|
618
642
|
iosBottom={20}
|
|
619
643
|
/>
|
|
620
644
|
)}
|
|
645
|
+
{webviewPaymethod?.gateway === 'paypal' && showGateway.open && (
|
|
646
|
+
<PaymentOptionsWebView
|
|
647
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
648
|
+
uri={`${ordering.root}/html/paypal_react_native`}
|
|
649
|
+
user={user}
|
|
650
|
+
token={token}
|
|
651
|
+
cart={cart}
|
|
652
|
+
currency={currency}
|
|
653
|
+
webviewPaymethod={webviewPaymethod}
|
|
654
|
+
setShowGateway={setShowGateway}
|
|
655
|
+
/>
|
|
656
|
+
)}
|
|
621
657
|
</>
|
|
622
658
|
)
|
|
623
659
|
}
|
|
@@ -48,7 +48,7 @@ export const Help = (props: HelpParams) => {
|
|
|
48
48
|
|
|
49
49
|
<LastOrdersContainer>
|
|
50
50
|
<OText size={18} weight={600}>{t('LAST_ORDERS', 'Last Orders')}</OText>
|
|
51
|
-
<LastOrders
|
|
51
|
+
<LastOrders {...props} onRedirect={onRedirect} />
|
|
52
52
|
</LastOrdersContainer>
|
|
53
53
|
</>
|
|
54
54
|
)
|