@blocklet/payment-react 1.14.21 → 1.14.23
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/README.md +77 -0
- package/es/checkout/donate.d.ts +4 -2
- package/es/checkout/donate.js +13 -10
- package/es/checkout/form.d.ts +1 -1
- package/es/checkout/form.js +50 -4
- package/es/checkout/table.d.ts +1 -1
- package/es/checkout/table.js +11 -1
- package/es/components/blockchain/tx.js +2 -1
- package/es/components/country-select.d.ts +16 -0
- package/es/components/country-select.js +82 -0
- package/es/components/input.d.ts +21 -21
- package/es/components/input.js +43 -42
- package/es/components/livemode.js +1 -0
- package/es/components/pricing-table.js +0 -2
- package/es/components/status.js +2 -3
- package/es/components/table.d.ts +2 -0
- package/es/components/table.js +186 -0
- package/es/contexts/payment.d.ts +2 -0
- package/es/contexts/payment.js +5 -2
- package/es/history/invoice/list.d.ts +3 -1
- package/es/history/invoice/list.js +215 -48
- package/es/hooks/mobile.d.ts +4 -0
- package/es/hooks/mobile.js +10 -0
- package/es/index.d.ts +5 -1
- package/es/index.js +7 -1
- package/es/libs/util.d.ts +21 -8
- package/es/libs/util.js +92 -28
- package/es/locales/en.js +22 -7
- package/es/locales/index.d.ts +0 -1
- package/es/locales/index.js +10 -1
- package/es/locales/zh.js +21 -6
- package/es/payment/error.js +2 -2
- package/es/payment/footer.js +1 -1
- package/es/payment/form/address.d.ts +9 -2
- package/es/payment/form/address.js +69 -69
- package/es/payment/form/currency.js +39 -25
- package/es/payment/form/index.d.ts +1 -1
- package/es/payment/form/index.js +83 -81
- package/es/payment/form/phone.js +15 -51
- package/es/payment/index.d.ts +3 -10
- package/es/payment/index.js +295 -224
- package/es/payment/product-card.js +4 -4
- package/es/payment/product-donation.js +9 -3
- package/es/payment/product-item.d.ts +2 -2
- package/es/payment/product-item.js +120 -81
- package/es/payment/summary.js +188 -118
- package/es/theme/index.css +240 -0
- package/es/theme/index.d.ts +14 -0
- package/es/theme/index.js +256 -0
- package/es/theme/typography.d.ts +2 -0
- package/es/theme/typography.js +53 -0
- package/es/types/index.d.ts +16 -0
- package/lib/checkout/donate.d.ts +4 -2
- package/lib/checkout/donate.js +23 -2
- package/lib/checkout/form.d.ts +1 -1
- package/lib/checkout/form.js +60 -15
- package/lib/checkout/table.d.ts +1 -1
- package/lib/checkout/table.js +22 -1
- package/lib/components/blockchain/tx.js +4 -1
- package/lib/components/country-select.d.ts +16 -0
- package/lib/components/country-select.js +115 -0
- package/lib/components/input.d.ts +21 -21
- package/lib/components/input.js +21 -12
- package/lib/components/livemode.js +1 -0
- package/lib/components/pricing-table.js +0 -2
- package/lib/components/status.js +2 -3
- package/lib/components/table.d.ts +2 -0
- package/lib/components/table.js +220 -0
- package/lib/contexts/payment.d.ts +2 -0
- package/lib/contexts/payment.js +4 -1
- package/lib/history/invoice/list.d.ts +3 -1
- package/lib/history/invoice/list.js +290 -62
- package/lib/hooks/mobile.d.ts +4 -0
- package/lib/hooks/mobile.js +17 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.js +36 -0
- package/lib/libs/util.d.ts +21 -8
- package/lib/libs/util.js +115 -37
- package/lib/locales/en.js +22 -7
- package/lib/locales/index.d.ts +0 -1
- package/lib/locales/index.js +14 -3
- package/lib/locales/zh.js +21 -6
- package/lib/payment/error.js +5 -1
- package/lib/payment/footer.js +1 -1
- package/lib/payment/form/address.d.ts +9 -2
- package/lib/payment/form/address.js +67 -59
- package/lib/payment/form/currency.js +31 -24
- package/lib/payment/form/index.d.ts +1 -1
- package/lib/payment/form/index.js +92 -93
- package/lib/payment/form/phone.js +11 -59
- package/lib/payment/index.d.ts +3 -10
- package/lib/payment/index.js +302 -225
- package/lib/payment/product-card.js +5 -4
- package/lib/payment/product-donation.js +11 -7
- package/lib/payment/product-item.d.ts +2 -2
- package/lib/payment/product-item.js +38 -19
- package/lib/payment/summary.js +219 -127
- package/lib/theme/index.css +240 -0
- package/lib/theme/index.d.ts +14 -0
- package/lib/theme/index.js +273 -0
- package/lib/theme/typography.d.ts +2 -0
- package/lib/theme/typography.js +59 -0
- package/lib/types/index.d.ts +16 -0
- package/package.json +14 -11
- package/src/checkout/donate.tsx +25 -11
- package/src/checkout/form.tsx +63 -15
- package/src/checkout/table.tsx +20 -1
- package/src/components/blockchain/tx.tsx +2 -1
- package/src/components/country-select.tsx +93 -0
- package/src/components/input.tsx +49 -46
- package/src/components/livemode.tsx +1 -0
- package/src/components/pricing-table.tsx +0 -2
- package/src/components/status.tsx +1 -2
- package/src/components/table.tsx +200 -0
- package/src/contexts/payment.tsx +6 -1
- package/src/history/invoice/list.tsx +254 -49
- package/src/hooks/mobile.ts +13 -0
- package/src/index.ts +7 -0
- package/src/libs/util.ts +120 -31
- package/src/locales/en.tsx +18 -4
- package/src/locales/index.tsx +10 -3
- package/src/locales/zh.tsx +17 -3
- package/src/payment/error.tsx +2 -2
- package/src/payment/footer.tsx +1 -1
- package/src/payment/form/address.tsx +56 -47
- package/src/payment/form/currency.tsx +29 -23
- package/src/payment/form/index.tsx +89 -76
- package/src/payment/form/phone.tsx +14 -51
- package/src/payment/index.tsx +298 -231
- package/src/payment/product-card.tsx +4 -4
- package/src/payment/product-donation.tsx +9 -4
- package/src/payment/product-item.tsx +49 -20
- package/src/payment/summary.tsx +191 -108
- package/src/theme/index.css +240 -0
- package/src/theme/index.tsx +271 -0
- package/src/theme/typography.ts +56 -0
- package/src/types/index.ts +17 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TPaymentCurrency } from '@blocklet/payment-types';
|
|
2
|
-
import { Avatar, Card, Stack, Typography } from '@mui/material';
|
|
2
|
+
import { Avatar, Card, Radio, Stack, Typography } from '@mui/material';
|
|
3
3
|
import { styled } from '@mui/system';
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
@@ -14,8 +14,9 @@ export default function CurrencySelector({ value, currencies, onChange }: Props)
|
|
|
14
14
|
count={currencies.length}
|
|
15
15
|
style={{
|
|
16
16
|
display: currencies.length > 1 ? 'grid' : 'block',
|
|
17
|
-
gridTemplateColumns: '50% 50%',
|
|
18
17
|
width: '100%',
|
|
18
|
+
gap: 12,
|
|
19
|
+
gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))',
|
|
19
20
|
}}>
|
|
20
21
|
{currencies.map((x, i) => {
|
|
21
22
|
const selected = i === value;
|
|
@@ -25,16 +26,26 @@ export default function CurrencySelector({ value, currencies, onChange }: Props)
|
|
|
25
26
|
variant="outlined"
|
|
26
27
|
onClick={() => onChange(i)}
|
|
27
28
|
className={selected ? 'cko-payment-card' : 'cko-payment-card-unselect'}>
|
|
28
|
-
<Stack direction="row" alignItems="center">
|
|
29
|
-
<Avatar src={x.logo} alt={x.name} sx={{ width:
|
|
29
|
+
<Stack direction="row" alignItems="center" sx={{ position: 'relative' }}>
|
|
30
|
+
<Avatar src={x.logo} alt={x.name} sx={{ width: 40, height: 40, marginRight: '12px' }} />
|
|
30
31
|
<div>
|
|
31
|
-
<Typography
|
|
32
|
+
<Typography
|
|
33
|
+
variant="h5"
|
|
34
|
+
component="div"
|
|
35
|
+
sx={{ fontSize: '16px', color: 'text.primary', fontWeight: '500' }}>
|
|
32
36
|
{x.symbol}
|
|
33
37
|
</Typography>
|
|
34
|
-
<Typography sx={{ fontSize: 14 }} color="text.
|
|
38
|
+
<Typography sx={{ fontSize: 14 }} color="text.lighter" gutterBottom>
|
|
35
39
|
{(x as any).method.name}
|
|
36
40
|
</Typography>
|
|
37
41
|
</div>
|
|
42
|
+
<Radio
|
|
43
|
+
checked={selected}
|
|
44
|
+
sx={{
|
|
45
|
+
position: 'absolute',
|
|
46
|
+
right: 0,
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
38
49
|
</Stack>
|
|
39
50
|
</Card>
|
|
40
51
|
);
|
|
@@ -46,32 +57,27 @@ export default function CurrencySelector({ value, currencies, onChange }: Props)
|
|
|
46
57
|
const Root = styled<any>('section')`
|
|
47
58
|
.cko-payment-card {
|
|
48
59
|
position: relative;
|
|
49
|
-
border: 1px solid
|
|
60
|
+
border: 1px solid var(--stroke-border-interactive, #0086ff);
|
|
50
61
|
padding: 4px 8px;
|
|
51
|
-
margin: 8px 0 0;
|
|
52
62
|
cursor: pointer;
|
|
63
|
+
background: var(--backgrounds-bg-field, #f9fafb);
|
|
53
64
|
}
|
|
54
65
|
|
|
55
|
-
.cko-payment-card::before {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
66
|
+
// .cko-payment-card::before {
|
|
67
|
+
// content: '';
|
|
68
|
+
// position: absolute;
|
|
69
|
+
// right: 0;
|
|
70
|
+
// bottom: 0;
|
|
71
|
+
// border: 12px solid ${(props) => props.theme.palette.primary.main};
|
|
72
|
+
// border-top-color: transparent;
|
|
73
|
+
// border-left-color: transparent;
|
|
74
|
+
// }
|
|
64
75
|
|
|
65
76
|
.cko-payment-card-unselect {
|
|
66
77
|
border: 1px solid #ddd;
|
|
67
78
|
padding: 4px 8px;
|
|
68
|
-
margin: 8px 0 0;
|
|
69
79
|
cursor: pointer;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
.cko-payment-card:nth-child(odd),
|
|
73
|
-
.cko-payment-card-unselect:nth-child(odd) {
|
|
74
|
-
margin-right: ${(props) => (props.count > 1 ? 8 : 0)}px;
|
|
80
|
+
background: var(--backgrounds-bg-field, #f9fafb);
|
|
75
81
|
}
|
|
76
82
|
|
|
77
83
|
.cko-payment-card::after {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'react-international-phone/style.css';
|
|
2
2
|
|
|
3
3
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
4
|
-
import { useTheme } from '@arcblock/ux/lib/Theme';
|
|
4
|
+
// import { useTheme } from '@arcblock/ux/lib/Theme';
|
|
5
5
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
6
6
|
import type {
|
|
7
7
|
TCheckoutSession,
|
|
@@ -11,8 +11,8 @@ import type {
|
|
|
11
11
|
TPaymentMethodExpanded,
|
|
12
12
|
} from '@blocklet/payment-types';
|
|
13
13
|
import { LoadingButton } from '@mui/lab';
|
|
14
|
-
import { Fade,
|
|
15
|
-
import {
|
|
14
|
+
import { Divider, Fade, FormLabel, Stack, Typography } from '@mui/material';
|
|
15
|
+
import { useMemoizedFn, useSetState } from 'ahooks';
|
|
16
16
|
import { PhoneNumberUtil } from 'google-libphonenumber';
|
|
17
17
|
import pWaitFor from 'p-wait-for';
|
|
18
18
|
import { useEffect, useMemo, useState } from 'react';
|
|
@@ -35,7 +35,6 @@ import {
|
|
|
35
35
|
getStatementDescriptor,
|
|
36
36
|
} from '../../libs/util';
|
|
37
37
|
import { CheckoutCallbacks, CheckoutContext } from '../../types';
|
|
38
|
-
import UserButtons from './addon';
|
|
39
38
|
import AddressForm from './address';
|
|
40
39
|
import CurrencySelector from './currency';
|
|
41
40
|
import PhoneInput from './phone';
|
|
@@ -93,12 +92,12 @@ export default function PaymentForm({
|
|
|
93
92
|
customer,
|
|
94
93
|
onPaid,
|
|
95
94
|
onError,
|
|
96
|
-
mode,
|
|
95
|
+
// mode,
|
|
97
96
|
action,
|
|
98
97
|
}: PageData) {
|
|
99
|
-
const theme = useTheme();
|
|
98
|
+
// const theme = useTheme();
|
|
100
99
|
const { t } = useLocaleContext();
|
|
101
|
-
const { session, connect } = usePaymentContext();
|
|
100
|
+
const { session, connect, payable } = usePaymentContext();
|
|
102
101
|
const subscription = useSubscription('events');
|
|
103
102
|
const { control, getValues, setValue, handleSubmit } = useFormContext();
|
|
104
103
|
const quantityInventoryStatus = useMemo(() => {
|
|
@@ -184,16 +183,16 @@ export default function PaymentForm({
|
|
|
184
183
|
|
|
185
184
|
const paymentMethod = useWatch({ control, name: 'payment_method' });
|
|
186
185
|
|
|
187
|
-
const domSize = useSize(document.body);
|
|
186
|
+
// const domSize = useSize(document.body);
|
|
188
187
|
|
|
189
|
-
const isColumnLayout = useCreation(() => {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}, [domSize, theme]);
|
|
188
|
+
// const isColumnLayout = useCreation(() => {
|
|
189
|
+
// if (domSize) {
|
|
190
|
+
// if (domSize?.width <= theme.breakpoints.values.md) {
|
|
191
|
+
// return true;
|
|
192
|
+
// }
|
|
193
|
+
// }
|
|
194
|
+
// return false;
|
|
195
|
+
// }, [domSize, theme]);
|
|
197
196
|
|
|
198
197
|
const afterUserLoggedIn = useMemoizedFn(() => {
|
|
199
198
|
if (hasDidWallet(session.user)) {
|
|
@@ -383,11 +382,54 @@ export default function PaymentForm({
|
|
|
383
382
|
<>
|
|
384
383
|
<Fade in>
|
|
385
384
|
<Stack className="cko-payment-contact">
|
|
385
|
+
<Typography
|
|
386
|
+
title={t('payment.checkout.paymentDetails')}
|
|
387
|
+
sx={{
|
|
388
|
+
color: 'text.primary',
|
|
389
|
+
fontSize: {
|
|
390
|
+
xs: '18px',
|
|
391
|
+
md: '24px',
|
|
392
|
+
},
|
|
393
|
+
fontWeight: '700',
|
|
394
|
+
lineHeight: '32px',
|
|
395
|
+
mb: 2.5,
|
|
396
|
+
}}>
|
|
397
|
+
{t('payment.checkout.paymentDetails')}
|
|
398
|
+
</Typography>
|
|
399
|
+
<Fade in>
|
|
400
|
+
<Stack direction="column" alignItems="flex-start" className="cko-payment-methods">
|
|
401
|
+
<Stack direction="row" sx={{ width: '100%' }}>
|
|
402
|
+
<Controller
|
|
403
|
+
name="payment_currency"
|
|
404
|
+
control={control}
|
|
405
|
+
render={() => (
|
|
406
|
+
<CurrencySelector
|
|
407
|
+
value={paymentCurrencyIndex}
|
|
408
|
+
currencies={currencies}
|
|
409
|
+
onChange={setPaymentCurrencyIndex}
|
|
410
|
+
/>
|
|
411
|
+
)}
|
|
412
|
+
/>
|
|
413
|
+
</Stack>
|
|
414
|
+
{state.stripePaying && state.stripeContext && (
|
|
415
|
+
<StripeCheckout
|
|
416
|
+
clientSecret={state.stripeContext.client_secret}
|
|
417
|
+
intentType={state.stripeContext.intent_type}
|
|
418
|
+
publicKey={method.settings.stripe?.publishable_key as string}
|
|
419
|
+
customer={state.customer as TCustomer}
|
|
420
|
+
mode={checkoutSession.mode}
|
|
421
|
+
onConfirm={onStripeConfirm}
|
|
422
|
+
onCancel={onStripeCancel}
|
|
423
|
+
/>
|
|
424
|
+
)}
|
|
425
|
+
</Stack>
|
|
426
|
+
</Fade>
|
|
386
427
|
<Stack direction="row" sx={{ mb: 1 }} alignItems="center" justifyContent="space-between">
|
|
387
|
-
<Typography sx={{ color: 'text.secondary', fontWeight: 600 }}>{t('payment.checkout.contact')}</Typography>
|
|
388
|
-
{isColumnLayout || mode !== 'standalone' ? null : <UserButtons />}
|
|
428
|
+
{/* <Typography sx={{ color: 'text.secondary', fontWeight: 600 }}>{t('payment.checkout.contact')}</Typography> */}
|
|
429
|
+
{/* {isColumnLayout || mode !== 'standalone' ? null : <UserButtons />} */}
|
|
389
430
|
</Stack>
|
|
390
|
-
<Stack direction="column" className="cko-payment-form" spacing={0}>
|
|
431
|
+
<Stack direction="column" className="cko-payment-form" spacing={0} sx={{ flex: 1, overflow: 'auto' }}>
|
|
432
|
+
<FormLabel className="base-label">{t('payment.checkout.customer.name')}</FormLabel>
|
|
391
433
|
<FormInput
|
|
392
434
|
name="customer_name"
|
|
393
435
|
variant="outlined"
|
|
@@ -395,10 +437,8 @@ export default function PaymentForm({
|
|
|
395
437
|
rules={{
|
|
396
438
|
required: t('payment.checkout.required'),
|
|
397
439
|
}}
|
|
398
|
-
InputProps={{
|
|
399
|
-
startAdornment: <InputAdornment position="start">{t('payment.checkout.customer.name')}</InputAdornment>,
|
|
400
|
-
}}
|
|
401
440
|
/>
|
|
441
|
+
<FormLabel className="base-label">{t('payment.checkout.customer.email')}</FormLabel>
|
|
402
442
|
<FormInput
|
|
403
443
|
name="customer_email"
|
|
404
444
|
variant="outlined"
|
|
@@ -407,64 +447,38 @@ export default function PaymentForm({
|
|
|
407
447
|
required: t('payment.checkout.required'),
|
|
408
448
|
validate: (x) => (isEmail(x) ? true : t('payment.checkout.invalid')),
|
|
409
449
|
}}
|
|
410
|
-
InputProps={{
|
|
411
|
-
startAdornment: (
|
|
412
|
-
<InputAdornment position="start">{t('payment.checkout.customer.email')}</InputAdornment>
|
|
413
|
-
),
|
|
414
|
-
}}
|
|
415
450
|
/>
|
|
416
451
|
{checkoutSession.phone_number_collection?.enabled && (
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
</Stack>
|
|
436
|
-
</Stack>
|
|
437
|
-
</Fade>
|
|
438
|
-
<AddressForm mode={checkoutSession.billing_address_collection as string} stripe={method?.type === 'stripe'} />
|
|
439
|
-
<Fade in>
|
|
440
|
-
<Stack direction="column" alignItems="flex-start" className="cko-payment-methods">
|
|
441
|
-
<Typography sx={{ color: 'text.secondary', fontWeight: 600 }}>{t('payment.checkout.method')}</Typography>
|
|
442
|
-
<Stack direction="row" sx={{ width: '100%' }}>
|
|
443
|
-
<Controller
|
|
444
|
-
name="payment_currency"
|
|
445
|
-
control={control}
|
|
446
|
-
render={() => (
|
|
447
|
-
<CurrencySelector
|
|
448
|
-
value={paymentCurrencyIndex}
|
|
449
|
-
currencies={currencies}
|
|
450
|
-
onChange={setPaymentCurrencyIndex}
|
|
452
|
+
<>
|
|
453
|
+
<FormLabel className="base-label">{t('payment.checkout.customer.phone')}</FormLabel>
|
|
454
|
+
<PhoneInput
|
|
455
|
+
name="customer_phone"
|
|
456
|
+
variant="outlined"
|
|
457
|
+
errorPosition="right"
|
|
458
|
+
placeholder="Phone number"
|
|
459
|
+
rules={{
|
|
460
|
+
required: t('payment.checkout.required'),
|
|
461
|
+
validate: (x: string) => {
|
|
462
|
+
try {
|
|
463
|
+
const parsed = phoneUtil.parseAndKeepRawInput(x);
|
|
464
|
+
return phoneUtil.isValidNumber(parsed) ? true : t('payment.checkout.invalid');
|
|
465
|
+
} catch {
|
|
466
|
+
return t('payment.checkout.invalid');
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
}}
|
|
451
470
|
/>
|
|
452
|
-
|
|
471
|
+
</>
|
|
472
|
+
)}
|
|
473
|
+
<AddressForm
|
|
474
|
+
mode={checkoutSession.billing_address_collection as string}
|
|
475
|
+
stripe={method?.type === 'stripe'}
|
|
476
|
+
sx={{ marginTop: '0 !important' }}
|
|
453
477
|
/>
|
|
454
478
|
</Stack>
|
|
455
|
-
{state.stripePaying && state.stripeContext && (
|
|
456
|
-
<StripeCheckout
|
|
457
|
-
clientSecret={state.stripeContext.client_secret}
|
|
458
|
-
intentType={state.stripeContext.intent_type}
|
|
459
|
-
publicKey={method.settings.stripe?.publishable_key as string}
|
|
460
|
-
customer={state.customer as TCustomer}
|
|
461
|
-
mode={checkoutSession.mode}
|
|
462
|
-
onConfirm={onStripeConfirm}
|
|
463
|
-
onCancel={onStripeCancel}
|
|
464
|
-
/>
|
|
465
|
-
)}
|
|
466
479
|
</Stack>
|
|
467
480
|
</Fade>
|
|
481
|
+
<Divider sx={{ mt: 2.5, mb: 2.5 }} />
|
|
468
482
|
<Fade in>
|
|
469
483
|
<Stack className="cko-payment-submit">
|
|
470
484
|
<LoadingButton
|
|
@@ -474,13 +488,12 @@ export default function PaymentForm({
|
|
|
474
488
|
className="cko-submit-button"
|
|
475
489
|
onClick={onAction}
|
|
476
490
|
fullWidth
|
|
477
|
-
disabled={state.submitting || state.paying || state.stripePaying || !quantityInventoryStatus}
|
|
491
|
+
disabled={state.submitting || state.paying || state.stripePaying || !quantityInventoryStatus || !payable}
|
|
478
492
|
loading={state.submitting || state.paying}>
|
|
479
493
|
{state.submitting || state.paying ? t('payment.checkout.processing') : buttonText}
|
|
480
494
|
</LoadingButton>
|
|
481
495
|
{['subscription', 'setup'].includes(checkoutSession.mode) && (
|
|
482
|
-
<Typography
|
|
483
|
-
sx={{ mt: 1, color: 'text.secondary', fontSize: '0.9rem', lineHeight: '1.1rem', textAlign: 'center' }}>
|
|
496
|
+
<Typography sx={{ mt: 2.5, color: 'text.lighter', fontSize: '0.9rem', lineHeight: '1.1rem' }}>
|
|
484
497
|
{t('payment.checkout.confirm', { payee })}
|
|
485
498
|
</Typography>
|
|
486
499
|
)}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/* eslint-disable react/prop-types */
|
|
2
|
-
import { InputAdornment
|
|
2
|
+
import { InputAdornment } from '@mui/material';
|
|
3
3
|
import omit from 'lodash/omit';
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
5
|
import { useFormContext, useWatch } from 'react-hook-form';
|
|
6
|
-
import { CountryIso2,
|
|
6
|
+
import { CountryIso2, defaultCountries, usePhoneInput } from 'react-international-phone';
|
|
7
7
|
|
|
8
8
|
import FormInput from '../../components/input';
|
|
9
9
|
import { isValidCountry } from '../../libs/util';
|
|
10
|
+
import CountrySelect from '../../components/country-select';
|
|
10
11
|
|
|
11
12
|
export default function PhoneInput({ ...props }) {
|
|
12
13
|
const countryFieldName = props.countryFieldName || 'billing_address.country';
|
|
13
|
-
|
|
14
14
|
const { control, getValues, setValue } = useFormContext();
|
|
15
15
|
const values = getValues();
|
|
16
16
|
|
|
@@ -20,11 +20,11 @@ export default function PhoneInput({ ...props }) {
|
|
|
20
20
|
countries: defaultCountries,
|
|
21
21
|
onChange: (data) => {
|
|
22
22
|
setValue(props.name, data.phone);
|
|
23
|
+
setValue(countryFieldName, data.country);
|
|
23
24
|
},
|
|
24
25
|
});
|
|
25
26
|
|
|
26
27
|
const userCountry = useWatch({ control, name: countryFieldName });
|
|
27
|
-
|
|
28
28
|
useEffect(() => {
|
|
29
29
|
if (userCountry !== country) {
|
|
30
30
|
setCountry(userCountry);
|
|
@@ -32,9 +32,9 @@ export default function PhoneInput({ ...props }) {
|
|
|
32
32
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
33
|
}, [userCountry]);
|
|
34
34
|
|
|
35
|
-
const onCountryChange = (
|
|
36
|
-
setCountry(
|
|
37
|
-
setValue(countryFieldName,
|
|
35
|
+
const onCountryChange = (v: CountryIso2) => {
|
|
36
|
+
setCountry(v);
|
|
37
|
+
setValue(countryFieldName, v);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
return (
|
|
@@ -47,53 +47,16 @@ export default function PhoneInput({ ...props }) {
|
|
|
47
47
|
InputProps={{
|
|
48
48
|
startAdornment: (
|
|
49
49
|
<InputAdornment position="start" style={{ marginRight: '2px', marginLeft: '-8px' }}>
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
width: '360px',
|
|
55
|
-
top: '10px',
|
|
56
|
-
left: '-34px',
|
|
57
|
-
},
|
|
58
|
-
transformOrigin: {
|
|
59
|
-
vertical: 'top',
|
|
60
|
-
horizontal: 'left',
|
|
61
|
-
},
|
|
62
|
-
}}
|
|
50
|
+
<CountrySelect
|
|
51
|
+
value={country}
|
|
52
|
+
onChange={onCountryChange}
|
|
53
|
+
name={countryFieldName}
|
|
63
54
|
sx={{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
fieldset: {
|
|
67
|
-
display: 'none',
|
|
68
|
-
},
|
|
69
|
-
'&.Mui-focused:has(div[aria-expanded="false"])': {
|
|
70
|
-
fieldset: {
|
|
71
|
-
display: 'block',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
// Update default spacing
|
|
75
|
-
'.MuiSelect-select': {
|
|
76
|
-
padding: '8px',
|
|
77
|
-
paddingRight: '24px !important',
|
|
78
|
-
},
|
|
79
|
-
svg: {
|
|
80
|
-
right: 0,
|
|
55
|
+
'&.Mui-focused .MuiOutlinedInput-notchedOutline': {
|
|
56
|
+
borderColor: 'transparent',
|
|
81
57
|
},
|
|
82
58
|
}}
|
|
83
|
-
|
|
84
|
-
onChange={onCountryChange}
|
|
85
|
-
renderValue={(code) => <FlagEmoji iso2={code} style={{ display: 'flex' }} />}>
|
|
86
|
-
{defaultCountries.map((c) => {
|
|
87
|
-
const parsed = parseCountry(c);
|
|
88
|
-
return (
|
|
89
|
-
<MenuItem key={parsed.iso2} value={parsed.iso2}>
|
|
90
|
-
<FlagEmoji iso2={parsed.iso2} style={{ marginRight: '8px' }} />
|
|
91
|
-
<Typography marginRight="8px">{parsed.name}</Typography>
|
|
92
|
-
<Typography color="gray">+{parsed.dialCode}</Typography>
|
|
93
|
-
</MenuItem>
|
|
94
|
-
);
|
|
95
|
-
})}
|
|
96
|
-
</Select>
|
|
59
|
+
/>
|
|
97
60
|
</InputAdornment>
|
|
98
61
|
),
|
|
99
62
|
}}
|