ordering-ui-react-native 0.19.4-release → 0.19.6-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 +1 -1
- package/themes/original/src/components/Checkout/index.tsx +8 -8
- package/themes/original/src/components/MultiCheckout/index.tsx +44 -3
- package/themes/original/src/components/MultiOrdersDetails/index.tsx +18 -13
- package/themes/original/src/components/PaymentOptionCard/index.tsx +4 -2
- package/themes/original/src/components/PaymentOptions/index.tsx +34 -1
- package/themes/original/src/components/StripeCardsList/index.tsx +2 -33
- package/themes/original/src/components/StripeElementsForm/index.tsx +4 -2
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
|
2
|
-
import { View, StyleSheet, TouchableOpacity, Platform, I18nManager, ScrollView, Keyboard, BackHandler } from 'react-native';
|
|
2
|
+
import { View, StyleSheet, TouchableOpacity, Platform, I18nManager, ScrollView, Keyboard, BackHandler, SafeAreaView } from 'react-native';
|
|
3
3
|
import { initStripe, useConfirmPayment } from '@stripe/stripe-react-native';
|
|
4
4
|
import NativeStripeSdk from '@stripe/stripe-react-native/src/NativeStripeSdk'
|
|
5
5
|
import Picker from 'react-native-country-picker-modal';
|
|
@@ -448,9 +448,9 @@ const CheckoutUI = (props: any) => {
|
|
|
448
448
|
|
|
449
449
|
return (
|
|
450
450
|
<>
|
|
451
|
-
<
|
|
452
|
-
<
|
|
453
|
-
|
|
451
|
+
<SafeAreaView style={{ backgroundColor: theme.colors.backgroundPage }}>
|
|
452
|
+
<View style={styles.wrapperNavbar}>
|
|
453
|
+
<TopHeader>
|
|
454
454
|
<TopActions onPress={() => onNavigationRedirect('BottomTab', { screen: 'Cart' }, !props.fromMulti)}>
|
|
455
455
|
<IconAntDesign
|
|
456
456
|
name='arrowleft'
|
|
@@ -468,10 +468,10 @@ const CheckoutUI = (props: any) => {
|
|
|
468
468
|
{t('CHECKOUT', 'Checkout')}
|
|
469
469
|
</OText>
|
|
470
470
|
)}
|
|
471
|
-
|
|
472
|
-
</
|
|
473
|
-
</
|
|
474
|
-
<Container forwardRef={containerRef} noPadding onScroll={handleScroll}>
|
|
471
|
+
</TopHeader>
|
|
472
|
+
</View>
|
|
473
|
+
</SafeAreaView>
|
|
474
|
+
<Container pt={0} forwardRef={containerRef} noPadding onScroll={handleScroll}>
|
|
475
475
|
<View style={styles.wrapperNavbar}>
|
|
476
476
|
<NavBar
|
|
477
477
|
hideArrowLeft
|
|
@@ -10,8 +10,9 @@ import {
|
|
|
10
10
|
ToastType,
|
|
11
11
|
MultiCheckout as MultiCheckoutController
|
|
12
12
|
} from 'ordering-components/native'
|
|
13
|
-
import { View, StyleSheet, Platform, ScrollView } from 'react-native'
|
|
13
|
+
import { View, StyleSheet, Platform, ScrollView, SafeAreaView } from 'react-native'
|
|
14
14
|
import { useTheme } from 'styled-components/native';
|
|
15
|
+
import IconAntDesign from 'react-native-vector-icons/AntDesign';
|
|
15
16
|
import { Container } from '../../layouts/Container';
|
|
16
17
|
import NavBar from '../NavBar';
|
|
17
18
|
import { OText, OIcon, OModal, OButton } from '../shared';
|
|
@@ -30,6 +31,8 @@ import { SignupForm } from '../SignupForm'
|
|
|
30
31
|
import { LoginForm } from '../LoginForm'
|
|
31
32
|
|
|
32
33
|
import {
|
|
34
|
+
TopHeader,
|
|
35
|
+
TopActions,
|
|
33
36
|
ChContainer,
|
|
34
37
|
ChSection,
|
|
35
38
|
ChHeader,
|
|
@@ -76,7 +79,11 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
76
79
|
paddingLeft: 20,
|
|
77
80
|
paddingRight: 20
|
|
78
81
|
},
|
|
79
|
-
wrapperNavbar: {
|
|
82
|
+
wrapperNavbar: {
|
|
83
|
+
paddingHorizontal: 20,
|
|
84
|
+
backgroundColor: theme?.colors?.white,
|
|
85
|
+
borderWidth: 0
|
|
86
|
+
},
|
|
80
87
|
detailWrapper: {
|
|
81
88
|
paddingHorizontal: 20,
|
|
82
89
|
width: '100%'
|
|
@@ -136,6 +143,7 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
136
143
|
?.reduce((sum: any, cart: any) => sum + clearAmount((cart?.subtotal + getIncludedTaxes(cart)) * accumulationRateBusiness(cart?.business_id)), 0)
|
|
137
144
|
?.toFixed(configs.format_number_decimal_length?.value ?? 2)
|
|
138
145
|
|
|
146
|
+
const [showTitle, setShowTitle] = useState(false)
|
|
139
147
|
const [isUserDetailsEdit, setIsUserDetailsEdit] = useState(false);
|
|
140
148
|
const [phoneUpdate, setPhoneUpdate] = useState(false);
|
|
141
149
|
const [userErrors, setUserErrors] = useState<any>([]);
|
|
@@ -233,6 +241,10 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
233
241
|
if (user) setOpenModal({ ...openModal, login: false })
|
|
234
242
|
}
|
|
235
243
|
|
|
244
|
+
const handleScroll = ({ nativeEvent: { contentOffset } }: any) => {
|
|
245
|
+
setShowTitle(contentOffset.y > 30)
|
|
246
|
+
}
|
|
247
|
+
|
|
236
248
|
useEffect(() => {
|
|
237
249
|
if (validationFields && validationFields?.fields?.checkout) {
|
|
238
250
|
checkValidationFields()
|
|
@@ -273,15 +285,44 @@ const MultiCheckoutUI = (props: any) => {
|
|
|
273
285
|
|
|
274
286
|
return (
|
|
275
287
|
<>
|
|
276
|
-
<
|
|
288
|
+
<SafeAreaView style={{ backgroundColor: theme.colors.backgroundPage }}>
|
|
289
|
+
<View style={styles.wrapperNavbar}>
|
|
290
|
+
<TopHeader>
|
|
291
|
+
<>
|
|
292
|
+
<TopActions onPress={() => navigation?.canGoBack() && navigation.goBack()}>
|
|
293
|
+
<IconAntDesign
|
|
294
|
+
name='arrowleft'
|
|
295
|
+
size={26}
|
|
296
|
+
/>
|
|
297
|
+
</TopActions>
|
|
298
|
+
{showTitle && (
|
|
299
|
+
<OText
|
|
300
|
+
size={16}
|
|
301
|
+
style={{ flex: 1, textAlign: 'center', right: 15 }}
|
|
302
|
+
weight={Platform.OS === 'ios' ? '600' : 'bold'}
|
|
303
|
+
numberOfLines={2}
|
|
304
|
+
ellipsizeMode='tail'
|
|
305
|
+
>
|
|
306
|
+
{t('CHECKOUT', 'Checkout')}
|
|
307
|
+
</OText>
|
|
308
|
+
)}
|
|
309
|
+
</>
|
|
310
|
+
</TopHeader>
|
|
311
|
+
</View>
|
|
312
|
+
</SafeAreaView>
|
|
313
|
+
<Container pt={0} noPadding onScroll={handleScroll}>
|
|
277
314
|
<View style={styles.wrapperNavbar}>
|
|
278
315
|
<NavBar
|
|
316
|
+
hideArrowLeft
|
|
279
317
|
title={t('CHECKOUT', 'Checkout')}
|
|
280
318
|
titleAlign={'center'}
|
|
281
319
|
onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
|
|
282
320
|
showCall={false}
|
|
283
321
|
paddingTop={Platform.OS === 'ios' ? 0 : 4}
|
|
284
322
|
btnStyle={{ paddingLeft: 0 }}
|
|
323
|
+
titleWrapStyle={{ paddingHorizontal: 0 }}
|
|
324
|
+
titleStyle={{ marginRight: 0, marginLeft: 0 }}
|
|
325
|
+
style={{ marginTop: 20 }}
|
|
285
326
|
/>
|
|
286
327
|
</View>
|
|
287
328
|
<ChContainer style={styles.pagePadding}>
|
|
@@ -53,6 +53,7 @@ export const MultiOrdersDetailsUI = (props: any) => {
|
|
|
53
53
|
const [{ configs }] = useConfig()
|
|
54
54
|
|
|
55
55
|
const isTaxIncludedOnPrice = orders.every((_order: any) => _order.taxes?.length ? _order.taxes?.every((_tax: any) => _tax.type === 1) : true)
|
|
56
|
+
const deliveryType = orders.find((order: any) => order.delivery_type)?.delivery_type
|
|
56
57
|
const progressBarStyle = configs.multi_business_checkout_progress_bar_style?.value
|
|
57
58
|
const showBarInOrder = ['group', 'both']
|
|
58
59
|
const showBarInIndividual = ['individual', 'both']
|
|
@@ -171,19 +172,23 @@ export const MultiOrdersDetailsUI = (props: any) => {
|
|
|
171
172
|
))}
|
|
172
173
|
</Section>
|
|
173
174
|
<Divider />
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
175
|
+
{deliveryType === 1 && (
|
|
176
|
+
<>
|
|
177
|
+
<Section>
|
|
178
|
+
<OText size={16} lineHeight={24} weight={'500'} color={theme.colors.textNormal} mBottom={20}>
|
|
179
|
+
{t('DELIVERYA_V21', 'Delivery address')}
|
|
180
|
+
</OText>
|
|
181
|
+
{loading ? (
|
|
182
|
+
<PlaceholderLine height={18} noMargin style={{ borderRadius: 2 }} />
|
|
183
|
+
) : (
|
|
184
|
+
<OText size={12} lineHeight={18} color={theme.colors.textNormal} mBottom={2}>
|
|
185
|
+
{customer?.address}
|
|
186
|
+
</OText>
|
|
187
|
+
)}
|
|
188
|
+
</Section>
|
|
189
|
+
<Divider />
|
|
190
|
+
</>
|
|
191
|
+
)}
|
|
187
192
|
{loading ? (
|
|
188
193
|
<Placeholder Animation={Fade}>
|
|
189
194
|
<PlaceholderLine
|
|
@@ -26,7 +26,7 @@ const PaymentOptionCardUI = (props: any) => {
|
|
|
26
26
|
const [alertState, setAlertState] = useState<{ open: boolean, content: Array<string> }>({ open: false, content: [] })
|
|
27
27
|
const [newCard, setNewCard] = useState<any>(null)
|
|
28
28
|
|
|
29
|
-
const onChangeCardForm = (values
|
|
29
|
+
const onChangeCardForm = (values: any) => {
|
|
30
30
|
if (values?.valid) {
|
|
31
31
|
const expiry = values?.values?.expiry?.split('/')
|
|
32
32
|
const expiryMonth = expiry[0]
|
|
@@ -107,6 +107,8 @@ const PaymentOptionCardUI = (props: any) => {
|
|
|
107
107
|
cardsList={cardsList}
|
|
108
108
|
noShowErrors
|
|
109
109
|
gateway={gateway}
|
|
110
|
+
onOpen={() => setAddCardOpen({ ...addCardOpen, stripe: true })}
|
|
111
|
+
onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
|
|
110
112
|
/>
|
|
111
113
|
</>
|
|
112
114
|
<Modal
|
|
@@ -169,7 +171,7 @@ const PaymentOptionCardUI = (props: any) => {
|
|
|
169
171
|
)
|
|
170
172
|
}
|
|
171
173
|
|
|
172
|
-
export const PaymentOptionCard = (props
|
|
174
|
+
export const PaymentOptionCard = (props: any) => {
|
|
173
175
|
const paymentOptions = {
|
|
174
176
|
...props,
|
|
175
177
|
UIComponent: PaymentOptionCardUI
|
|
@@ -364,6 +364,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
364
364
|
methodPaySupported={methodPaySupported}
|
|
365
365
|
placeByMethodPay={placeByMethodPay}
|
|
366
366
|
setPlaceByMethodPay={setPlaceByMethodPay}
|
|
367
|
+
publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable}
|
|
367
368
|
/>
|
|
368
369
|
)}
|
|
369
370
|
|
|
@@ -406,6 +407,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
406
407
|
handleSource={handlePaymethodDataChange}
|
|
407
408
|
onCancel={() => handlePaymethodClick(null)}
|
|
408
409
|
merchantId={merchantId}
|
|
410
|
+
publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable}
|
|
409
411
|
/>
|
|
410
412
|
</KeyboardAvoidingView>
|
|
411
413
|
</OModal>
|
|
@@ -425,11 +427,12 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
425
427
|
<StripeCardsList
|
|
426
428
|
paymethod={isOpenMethod?.paymethod}
|
|
427
429
|
businessId={props.businessId}
|
|
428
|
-
publicKey={isOpenMethod?.paymethod?.credentials.publishable}
|
|
429
430
|
payType={paymethodsList?.name}
|
|
430
431
|
onSelectCard={handlePaymethodDataChange}
|
|
431
432
|
onNavigationRedirect={onNavigationRedirect}
|
|
432
433
|
onCancel={() => handlePaymethodClick(null)}
|
|
434
|
+
publicKey={isOpenMethod?.paymethod?.credentials.publishable}
|
|
435
|
+
publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable}
|
|
433
436
|
/>
|
|
434
437
|
</View>
|
|
435
438
|
)}
|
|
@@ -446,6 +449,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
446
449
|
enabled={Platform.OS === 'ios' ? true : false}
|
|
447
450
|
>
|
|
448
451
|
<StripeElementsForm
|
|
452
|
+
openCarts={props.openCarts}
|
|
449
453
|
toSave
|
|
450
454
|
businessId={props.businessId}
|
|
451
455
|
publicKey={isOpenMethod?.paymethod?.credentials?.stripe?.publishable}
|
|
@@ -453,6 +457,35 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
453
457
|
accountId={isOpenMethod?.paymethod?.credentials?.user}
|
|
454
458
|
onSelectCard={handlePaymethodDataChange}
|
|
455
459
|
onCancel={() => setAddCardOpen({ ...addCardOpen, stripeConnect: false })}
|
|
460
|
+
publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable}
|
|
461
|
+
/>
|
|
462
|
+
</KeyboardAvoidingView>
|
|
463
|
+
</OModal>
|
|
464
|
+
|
|
465
|
+
{/* Stripe Add card */}
|
|
466
|
+
<OModal
|
|
467
|
+
entireModal
|
|
468
|
+
title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
|
|
469
|
+
open={addCardOpen?.stripe}
|
|
470
|
+
onClose={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
|
|
471
|
+
style={{ backgroundColor: 'red' }}
|
|
472
|
+
>
|
|
473
|
+
<KeyboardAvoidingView
|
|
474
|
+
behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
|
|
475
|
+
keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
|
|
476
|
+
enabled={Platform.OS === 'ios' ? true : false}
|
|
477
|
+
>
|
|
478
|
+
<StripeElementsForm
|
|
479
|
+
openCarts={props.openCarts}
|
|
480
|
+
toSave
|
|
481
|
+
businessId={props.businessId}
|
|
482
|
+
businessIds={props.businessIds}
|
|
483
|
+
publicKey={props.publicKey || isOpenMethod?.paymethod?.credentials?.publishable}
|
|
484
|
+
setCardsList={setCardList}
|
|
485
|
+
requirements={props.clientSecret}
|
|
486
|
+
onSelectCard={handlePaymethodDataChange}
|
|
487
|
+
onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
|
|
488
|
+
publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable}
|
|
456
489
|
/>
|
|
457
490
|
</KeyboardAvoidingView>
|
|
458
491
|
</OModal>
|
|
@@ -29,12 +29,8 @@ export const StripeCardsListUI = (props: any) => {
|
|
|
29
29
|
cardSelected,
|
|
30
30
|
cardsList,
|
|
31
31
|
handleCardClick,
|
|
32
|
-
|
|
32
|
+
onOpen,
|
|
33
33
|
gateway,
|
|
34
|
-
setCardsList,
|
|
35
|
-
addCardOpen,
|
|
36
|
-
isOpenMethod,
|
|
37
|
-
handlePaymethodDataChange
|
|
38
34
|
} = props;
|
|
39
35
|
|
|
40
36
|
const theme = useTheme();
|
|
@@ -54,7 +50,7 @@ export const StripeCardsListUI = (props: any) => {
|
|
|
54
50
|
|
|
55
51
|
useEffect(() => {
|
|
56
52
|
if (!cardsList?.loading && cardsList?.cards?.length === 0 && !paymethodsWithoutSaveCards.includes(gateway)) {
|
|
57
|
-
|
|
53
|
+
onOpen && onOpen();
|
|
58
54
|
}
|
|
59
55
|
}, [cardsList?.loading])
|
|
60
56
|
|
|
@@ -147,33 +143,6 @@ export const StripeCardsListUI = (props: any) => {
|
|
|
147
143
|
))}
|
|
148
144
|
</ScrollView>
|
|
149
145
|
)}
|
|
150
|
-
<OModal
|
|
151
|
-
entireModal
|
|
152
|
-
title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
|
|
153
|
-
open={addCardOpen.stripe}
|
|
154
|
-
onClose={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
|
|
155
|
-
style={{ backgroundColor: 'red' }}
|
|
156
|
-
>
|
|
157
|
-
<KeyboardAvoidingView
|
|
158
|
-
behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
|
|
159
|
-
keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
|
|
160
|
-
enabled={Platform.OS === 'ios' ? true : false}
|
|
161
|
-
>
|
|
162
|
-
<StripeElementsForm
|
|
163
|
-
openCarts={props.openCarts}
|
|
164
|
-
toSave
|
|
165
|
-
businessId={props.businessId}
|
|
166
|
-
businessIds={props.businessIds}
|
|
167
|
-
publicKey={props.publicKey || isOpenMethod?.paymethod?.credentials?.publishable}
|
|
168
|
-
setCardsList={setCardsList}
|
|
169
|
-
cardsList={cardsList}
|
|
170
|
-
requirements={props.clientSecret}
|
|
171
|
-
handleCardClick={handleCardClick}
|
|
172
|
-
onSelectCard={handlePaymethodDataChange}
|
|
173
|
-
onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
|
|
174
|
-
/>
|
|
175
|
-
</KeyboardAvoidingView>
|
|
176
|
-
</OModal>
|
|
177
146
|
</>
|
|
178
147
|
)
|
|
179
148
|
}
|
|
@@ -33,7 +33,8 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
33
33
|
placeByMethodPay,
|
|
34
34
|
methodPaySupported,
|
|
35
35
|
setPlaceByMethodPay,
|
|
36
|
-
cartTotal
|
|
36
|
+
cartTotal,
|
|
37
|
+
publicKeyAddCard
|
|
37
38
|
} = props;
|
|
38
39
|
|
|
39
40
|
const theme = useTheme();
|
|
@@ -52,6 +53,7 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
52
53
|
const [isKeyboardShow, setIsKeyboardShow] = useState(false);
|
|
53
54
|
const zipCodeEnabled = validationFields?.fields?.card?.zipcode?.enabled
|
|
54
55
|
const zipCodeRequired = validationFields?.fields?.card?.zipcode?.required
|
|
56
|
+
const isToSave = methodsPay?.includes(paymethod) ? publicKey : publicKeyAddCard
|
|
55
57
|
const styles = StyleSheet.create({
|
|
56
58
|
container: {
|
|
57
59
|
width: '100%',
|
|
@@ -200,7 +202,7 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
200
202
|
{publicKey ? (
|
|
201
203
|
<View style={{ flex: 1 }}>
|
|
202
204
|
<StripeProvider
|
|
203
|
-
publishableKey={
|
|
205
|
+
publishableKey={isToSave}
|
|
204
206
|
merchantIdentifier={merchantId}
|
|
205
207
|
urlScheme={merchantId}
|
|
206
208
|
>
|