payment-kit 1.13.111 → 1.13.113
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/api/src/libs/notification/template/subscription-trial-will-end.ts +1 -1
- package/api/src/libs/notification/template/subscription-will-renew.ts +1 -1
- package/api/src/routes/products.ts +1 -0
- package/api/src/routes/subscriptions.ts +2 -0
- package/blocklet.yml +1 -1
- package/package.json +6 -6
- package/src/components/actions.tsx +1 -2
- package/src/components/blockchain/tx.tsx +1 -1
- package/src/components/click-boundary.tsx +1 -2
- package/src/components/customer/actions.tsx +2 -3
- package/src/components/customer/edit.tsx +3 -3
- package/src/components/customer/form.tsx +22 -24
- package/src/components/drawer-form.tsx +2 -4
- package/src/components/event/list.tsx +2 -3
- package/src/components/invoice/action.tsx +2 -3
- package/src/components/invoice/list.tsx +3 -4
- package/src/components/invoice/table.tsx +7 -7
- package/src/components/metadata/form.tsx +3 -4
- package/src/components/passport/actions.tsx +1 -2
- package/src/components/passport/assign.tsx +1 -1
- package/src/components/payment-intent/actions.tsx +2 -3
- package/src/components/payment-intent/list.tsx +3 -4
- package/src/components/payment-link/actions.tsx +2 -3
- package/src/components/payment-link/item.tsx +3 -5
- package/src/components/payment-link/product-select.tsx +3 -4
- package/src/components/payment-link/rename.tsx +3 -4
- package/src/components/payment-method/arcblock.tsx +1 -2
- package/src/components/payment-method/bitcoin.tsx +1 -2
- package/src/components/payment-method/ethereum.tsx +1 -2
- package/src/components/payment-method/stripe.tsx +1 -2
- package/src/components/portal/invoice/list.tsx +4 -5
- package/src/components/portal/subscription/actions.tsx +7 -8
- package/src/components/portal/subscription/cancel.tsx +13 -12
- package/src/components/portal/subscription/list.tsx +4 -10
- package/src/components/price/currency-select.tsx +2 -2
- package/src/components/price/form.tsx +3 -4
- package/src/components/price/upsell-select.tsx +2 -3
- package/src/components/price/upsell.tsx +3 -5
- package/src/components/pricing-table/actions.tsx +2 -3
- package/src/components/pricing-table/payment-settings.tsx +4 -4
- package/src/components/pricing-table/price-item.tsx +4 -7
- package/src/components/pricing-table/product-item.tsx +3 -3
- package/src/components/pricing-table/rename.tsx +3 -4
- package/src/components/product/actions.tsx +2 -3
- package/src/components/product/add-price.tsx +2 -2
- package/src/components/product/create.tsx +2 -4
- package/src/components/product/cross-sell-select.tsx +3 -3
- package/src/components/product/cross-sell.tsx +4 -5
- package/src/components/product/edit.tsx +1 -1
- package/src/components/product/form.tsx +6 -6
- package/src/components/relative-time.tsx +1 -2
- package/src/components/subscription/actions/cancel.tsx +2 -3
- package/src/components/subscription/actions/index.tsx +2 -3
- package/src/components/subscription/items/actions.tsx +1 -1
- package/src/components/subscription/items/index.tsx +2 -2
- package/src/components/subscription/items/usage-records.tsx +2 -3
- package/src/components/subscription/list.tsx +3 -4
- package/src/components/subscription/metrics.tsx +2 -2
- package/src/components/subscription/status.tsx +3 -3
- package/src/components/webhook/attempts.tsx +3 -3
- package/src/contexts/products.tsx +2 -3
- package/src/libs/api.ts +2 -19
- package/src/libs/dayjs.ts +1 -15
- package/src/libs/util.ts +24 -555
- package/src/locales/en.tsx +0 -139
- package/src/locales/index.tsx +5 -23
- package/src/locales/zh.tsx +0 -136
- package/src/pages/admin/billing/index.tsx +4 -2
- package/src/pages/admin/billing/invoices/detail.tsx +3 -4
- package/src/pages/admin/billing/subscriptions/detail.tsx +3 -3
- package/src/pages/admin/customers/customers/detail.tsx +3 -5
- package/src/pages/admin/customers/customers/index.tsx +2 -3
- package/src/pages/admin/customers/index.tsx +4 -2
- package/src/pages/admin/developers/events/detail.tsx +2 -3
- package/src/pages/admin/developers/index.tsx +4 -2
- package/src/pages/admin/developers/webhooks/detail.tsx +3 -4
- package/src/pages/admin/developers/webhooks/index.tsx +3 -4
- package/src/pages/admin/index.tsx +10 -7
- package/src/pages/admin/payments/index.tsx +4 -2
- package/src/pages/admin/payments/intents/detail.tsx +4 -6
- package/src/pages/admin/payments/links/create.tsx +3 -5
- package/src/pages/admin/payments/links/detail.tsx +4 -5
- package/src/pages/admin/payments/links/index.tsx +4 -6
- package/src/pages/admin/products/passports/index.tsx +1 -1
- package/src/pages/admin/products/prices/actions.tsx +2 -3
- package/src/pages/admin/products/prices/detail.tsx +2 -3
- package/src/pages/admin/products/prices/list.tsx +2 -4
- package/src/pages/admin/products/pricing-tables/create.tsx +2 -3
- package/src/pages/admin/products/pricing-tables/detail.tsx +4 -5
- package/src/pages/admin/products/pricing-tables/index.tsx +2 -4
- package/src/pages/admin/products/products/create.tsx +2 -4
- package/src/pages/admin/products/products/detail.tsx +4 -5
- package/src/pages/admin/products/products/index.tsx +4 -6
- package/src/pages/admin/settings/index.tsx +4 -2
- package/src/pages/admin/settings/payment-methods/create.tsx +3 -5
- package/src/pages/admin/settings/payment-methods/index.tsx +2 -3
- package/src/pages/checkout/index.tsx +6 -3
- package/src/pages/checkout/pay.tsx +5 -69
- package/src/pages/checkout/pricing-table.tsx +3 -7
- package/src/pages/customer/index.tsx +7 -7
- package/src/pages/customer/invoice.tsx +10 -11
- package/src/pages/customer/subscription/detail.tsx +4 -4
- package/src/pages/customer/subscription/update.tsx +19 -19
- package/src/components/checkout/amount.tsx +0 -24
- package/src/components/checkout/error.tsx +0 -30
- package/src/components/checkout/footer.tsx +0 -12
- package/src/components/checkout/form/address.tsx +0 -119
- package/src/components/checkout/form/index.tsx +0 -400
- package/src/components/checkout/form/phone.tsx +0 -103
- package/src/components/checkout/form/stripe.tsx +0 -195
- package/src/components/checkout/form/user-buttons.tsx +0 -24
- package/src/components/checkout/header.tsx +0 -40
- package/src/components/checkout/pay.tsx +0 -385
- package/src/components/checkout/pricing-table.tsx +0 -205
- package/src/components/checkout/product-card.tsx +0 -52
- package/src/components/checkout/product-item.tsx +0 -111
- package/src/components/checkout/skeleton/overview.tsx +0 -21
- package/src/components/checkout/skeleton/payment.tsx +0 -35
- package/src/components/checkout/success.tsx +0 -183
- package/src/components/checkout/summary.tsx +0 -198
- package/src/components/input.tsx +0 -58
- package/src/components/livemode.tsx +0 -23
- package/src/components/pricing-table/product-skeleton.tsx +0 -39
- package/src/components/status.tsx +0 -19
- package/src/components/switch.tsx +0 -48
- package/src/contexts/settings.tsx +0 -54
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
-
|
|
4
|
-
import FormInput from '../input';
|
|
3
|
+
import { FormInput } from '@blocklet/payment-react';
|
|
5
4
|
|
|
6
5
|
export default function BitcoinMethodForm() {
|
|
7
6
|
const { t } = useLocaleContext();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
-
|
|
4
|
-
import FormInput from '../input';
|
|
3
|
+
import { FormInput } from '@blocklet/payment-react';
|
|
5
4
|
|
|
6
5
|
export default function EthereumMethodForm() {
|
|
7
6
|
const { t } = useLocaleContext();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
-
|
|
4
|
-
import FormInput from '../input';
|
|
3
|
+
import { FormInput } from '@blocklet/payment-react';
|
|
5
4
|
|
|
6
5
|
export default function StripeMethodForm() {
|
|
7
6
|
const { t } = useLocaleContext();
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/* eslint-disable react/no-unstable-nested-components */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
-
import
|
|
3
|
+
import { Status, api, formatToDate } from '@blocklet/payment-react';
|
|
4
|
+
import type { Paginated, TInvoiceExpanded } from '@blocklet/payment-types';
|
|
4
5
|
import { Box, Button, CircularProgress, Stack, Typography } from '@mui/material';
|
|
5
6
|
import { fromUnitToToken } from '@ocap/util';
|
|
6
7
|
import { useInfiniteScroll } from 'ahooks';
|
|
7
8
|
import { Link } from 'react-router-dom';
|
|
8
9
|
|
|
9
|
-
import
|
|
10
|
-
import { formatToDate, getInvoiceStatusColor } from '../../../libs/util';
|
|
11
|
-
import Status from '../../status';
|
|
10
|
+
import { getInvoiceStatusColor } from '../../../libs/util';
|
|
12
11
|
|
|
13
12
|
const groupByDate = (items: TInvoiceExpanded[]) => {
|
|
14
13
|
const grouped: { [key: string]: TInvoiceExpanded[] } = {};
|
|
@@ -56,7 +55,7 @@ export default function CustomerInvoiceList({ customer_id }: Props) {
|
|
|
56
55
|
if (data && data.list.length === 0) {
|
|
57
56
|
return (
|
|
58
57
|
<Typography color="text.secondary">
|
|
59
|
-
{customer_id ? t('customer.invoice.empty') : t('admin.invoice.empty')}
|
|
58
|
+
{customer_id ? t('payment.customer.invoice.empty') : t('admin.invoice.empty')}
|
|
60
59
|
</Typography>
|
|
61
60
|
);
|
|
62
61
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/* eslint-disable react/no-unstable-nested-components */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
3
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
4
|
-
import
|
|
4
|
+
import { api, formatError, formatToDate, getSubscriptionAction } from '@blocklet/payment-react';
|
|
5
|
+
import type { TSubscriptionExpanded } from '@blocklet/payment-types';
|
|
5
6
|
import { Button, Stack } from '@mui/material';
|
|
6
7
|
import { useRequest, useSetState } from 'ahooks';
|
|
7
8
|
import { FormProvider, useForm, useFormContext } from 'react-hook-form';
|
|
8
9
|
import { useNavigate } from 'react-router-dom';
|
|
9
10
|
|
|
10
|
-
import api from '../../../libs/api';
|
|
11
|
-
import { formatError, formatToDate, getSubscriptionAction } from '../../../libs/util';
|
|
12
11
|
import ConfirmDialog from '../../confirm';
|
|
13
12
|
import CustomerCancelForm from './cancel';
|
|
14
13
|
|
|
@@ -92,7 +91,7 @@ export function SubscriptionActionsInner({ subscription, showUpdate, onChange }:
|
|
|
92
91
|
});
|
|
93
92
|
}
|
|
94
93
|
}}>
|
|
95
|
-
{t(`customer.${action.action}.button`)}
|
|
94
|
+
{t(`payment.customer.${action.action}.button`)}
|
|
96
95
|
</Button>
|
|
97
96
|
)}
|
|
98
97
|
{data && (
|
|
@@ -103,14 +102,14 @@ export function SubscriptionActionsInner({ subscription, showUpdate, onChange }:
|
|
|
103
102
|
onClick={() => {
|
|
104
103
|
navigate(`/customer/subscription/${subscription.id}/update`);
|
|
105
104
|
}}>
|
|
106
|
-
{t('customer.upgrade.button')}
|
|
105
|
+
{t('payment.customer.upgrade.button')}
|
|
107
106
|
</Button>
|
|
108
107
|
)}
|
|
109
108
|
{state.action === 'cancel' && state.subscription && (
|
|
110
109
|
<ConfirmDialog
|
|
111
110
|
onConfirm={handleCancel}
|
|
112
111
|
onCancel={() => setState({ action: '', subscription: '' })}
|
|
113
|
-
title={t('customer.cancel.title')}
|
|
112
|
+
title={t('payment.customer.cancel.title')}
|
|
114
113
|
message={<CustomerCancelForm data={subscription} />}
|
|
115
114
|
loading={state.loading}
|
|
116
115
|
/>
|
|
@@ -119,8 +118,8 @@ export function SubscriptionActionsInner({ subscription, showUpdate, onChange }:
|
|
|
119
118
|
<ConfirmDialog
|
|
120
119
|
onConfirm={handleRecover}
|
|
121
120
|
onCancel={() => setState({ action: '', subscription: '' })}
|
|
122
|
-
title={t('customer.recover.title')}
|
|
123
|
-
message={t('customer.recover.description', {
|
|
121
|
+
title={t('payment.customer.recover.title')}
|
|
122
|
+
message={t('payment.customer.recover.description', {
|
|
124
123
|
date: formatToDate(subscription.current_period_end * 1000),
|
|
125
124
|
})}
|
|
126
125
|
loading={state.loading}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
|
-
import
|
|
2
|
+
import { formatTime } from '@blocklet/payment-react';
|
|
3
|
+
import type { TSubscriptionExpanded } from '@blocklet/payment-types';
|
|
3
4
|
import { FormControlLabel, Radio, RadioGroup, Stack, TextField, Typography } from '@mui/material';
|
|
4
5
|
import { Controller, useFormContext } from 'react-hook-form';
|
|
5
6
|
|
|
6
|
-
import { formatTime } from '../../../libs/util';
|
|
7
|
-
|
|
8
7
|
export default function CustomerCancelForm({ data }: { data: TSubscriptionExpanded }) {
|
|
9
8
|
const { t } = useLocaleContext();
|
|
10
9
|
const { control } = useFormContext();
|
|
11
10
|
|
|
12
11
|
return (
|
|
13
12
|
<Stack direction="column" spacing={1} alignItems="flex-start">
|
|
14
|
-
<Typography>
|
|
13
|
+
<Typography>
|
|
14
|
+
{t('payment.customer.cancel.description', { date: formatTime(data.current_period_end * 1000) })}
|
|
15
|
+
</Typography>
|
|
15
16
|
<Controller
|
|
16
17
|
name="cancel.feedback"
|
|
17
18
|
control={control}
|
|
@@ -20,44 +21,44 @@ export default function CustomerCancelForm({ data }: { data: TSubscriptionExpand
|
|
|
20
21
|
<FormControlLabel
|
|
21
22
|
value="too_expensive"
|
|
22
23
|
control={<Radio checked={field.value === 'too_expensive'} />}
|
|
23
|
-
label={t('customer.cancel.feedback.too_expensive')}
|
|
24
|
+
label={t('payment.customer.cancel.feedback.too_expensive')}
|
|
24
25
|
/>
|
|
25
26
|
<FormControlLabel
|
|
26
27
|
value="missing_features"
|
|
27
28
|
control={<Radio checked={field.value === 'missing_features'} />}
|
|
28
|
-
label={t('customer.cancel.feedback.missing_features', {
|
|
29
|
+
label={t('payment.customer.cancel.feedback.missing_features', {
|
|
29
30
|
date: formatTime(new Date(data.current_period_end * 1000)),
|
|
30
31
|
})}
|
|
31
32
|
/>
|
|
32
33
|
<FormControlLabel
|
|
33
34
|
value="switched_service"
|
|
34
35
|
control={<Radio checked={field.value === 'switched_service'} />}
|
|
35
|
-
label={t('customer.cancel.feedback.switched_service')}
|
|
36
|
+
label={t('payment.customer.cancel.feedback.switched_service')}
|
|
36
37
|
/>
|
|
37
38
|
<FormControlLabel
|
|
38
39
|
value="unused"
|
|
39
40
|
control={<Radio checked={field.value === 'unused'} />}
|
|
40
|
-
label={t('customer.cancel.feedback.unused')}
|
|
41
|
+
label={t('payment.customer.cancel.feedback.unused')}
|
|
41
42
|
/>
|
|
42
43
|
<FormControlLabel
|
|
43
44
|
value="customer_service"
|
|
44
45
|
control={<Radio checked={field.value === 'customer_service'} />}
|
|
45
|
-
label={t('customer.cancel.feedback.customer_service')}
|
|
46
|
+
label={t('payment.customer.cancel.feedback.customer_service')}
|
|
46
47
|
/>
|
|
47
48
|
<FormControlLabel
|
|
48
49
|
value="too_complex"
|
|
49
50
|
control={<Radio checked={field.value === 'too_complex'} />}
|
|
50
|
-
label={t('customer.cancel.feedback.too_complex')}
|
|
51
|
+
label={t('payment.customer.cancel.feedback.too_complex')}
|
|
51
52
|
/>
|
|
52
53
|
<FormControlLabel
|
|
53
54
|
value="low_quality"
|
|
54
55
|
control={<Radio checked={field.value === 'low_quality'} />}
|
|
55
|
-
label={t('customer.cancel.feedback.low_quality')}
|
|
56
|
+
label={t('payment.customer.cancel.feedback.low_quality')}
|
|
56
57
|
/>
|
|
57
58
|
<FormControlLabel
|
|
58
59
|
value="other"
|
|
59
60
|
control={<Radio checked={field.value === 'other'} />}
|
|
60
|
-
label={t('customer.cancel.feedback.other')}
|
|
61
|
+
label={t('payment.customer.cancel.feedback.other')}
|
|
61
62
|
/>
|
|
62
63
|
</RadioGroup>
|
|
63
64
|
)}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
/* eslint-disable react/no-unstable-nested-components */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
-
import
|
|
3
|
+
import { Status, api, formatPrice, getSubscriptionTimeSummary } from '@blocklet/payment-react';
|
|
4
|
+
import type { Paginated, TSubscriptionExpanded } from '@blocklet/payment-types';
|
|
4
5
|
import { Avatar, AvatarGroup, Box, Button, CircularProgress, Stack, StackProps, Typography } from '@mui/material';
|
|
5
6
|
import { useInfiniteScroll } from 'ahooks';
|
|
6
7
|
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
formatPrice,
|
|
10
|
-
formatSubscriptionProduct,
|
|
11
|
-
getSubscriptionStatusColor,
|
|
12
|
-
getSubscriptionTimeSummary,
|
|
13
|
-
} from '../../../libs/util';
|
|
14
|
-
import Status from '../../status';
|
|
8
|
+
import { formatSubscriptionProduct, getSubscriptionStatusColor } from '../../../libs/util';
|
|
15
9
|
import SubscriptionActions from './actions';
|
|
16
10
|
|
|
17
11
|
const fetchData = (params: Record<string, any> = {}): Promise<Paginated<TSubscriptionExpanded>> => {
|
|
@@ -48,7 +42,7 @@ export default function CurrentSubscriptions({ id, onChange, onClickSubscription
|
|
|
48
42
|
}
|
|
49
43
|
|
|
50
44
|
if (data && data.list.length === 0) {
|
|
51
|
-
return <Typography color="text.secondary">{t('customer.subscriptions.empty')}</Typography>;
|
|
45
|
+
return <Typography color="text.secondary">{t('payment.customer.subscriptions.empty')}</Typography>;
|
|
52
46
|
}
|
|
53
47
|
|
|
54
48
|
const hasMore = data && data.list.length < data.count;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
|
+
import { usePaymentContext } from '@blocklet/payment-react';
|
|
2
3
|
import { AddOutlined } from '@mui/icons-material';
|
|
3
4
|
import { ListSubheader, MenuItem, Select, Stack, Typography } from '@mui/material';
|
|
4
5
|
import { useState } from 'react';
|
|
5
6
|
import type { LiteralUnion } from 'type-fest';
|
|
6
7
|
|
|
7
|
-
import { useSettingsContext } from '../../contexts/settings';
|
|
8
8
|
import { getSupportedPaymentMethods } from '../../libs/util';
|
|
9
9
|
import Currency from '../currency';
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ type Props = {
|
|
|
16
16
|
|
|
17
17
|
export default function CurrencySelect({ mode: initialMode, hasSelected, onSelect }: Props) {
|
|
18
18
|
const { t } = useLocaleContext();
|
|
19
|
-
const { settings } =
|
|
19
|
+
const { settings } = usePaymentContext();
|
|
20
20
|
const [mode, setMode] = useState(initialMode);
|
|
21
21
|
|
|
22
22
|
const handleSelect = (e: any) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
-
import
|
|
3
|
+
import { findCurrency, usePaymentContext } from '@blocklet/payment-react';
|
|
4
|
+
import type { InferFormType, PriceRecurring, TPaymentMethodExpanded, TPriceExpanded } from '@blocklet/payment-types';
|
|
4
5
|
import { DeleteOutlineOutlined, InfoOutlined } from '@mui/icons-material';
|
|
5
6
|
import {
|
|
6
7
|
Alert,
|
|
@@ -23,8 +24,6 @@ import { styled } from '@mui/system';
|
|
|
23
24
|
import { Controller, useFieldArray, useFormContext, useWatch } from 'react-hook-form';
|
|
24
25
|
import type { LiteralUnion } from 'type-fest';
|
|
25
26
|
|
|
26
|
-
import { useSettingsContext } from '../../contexts/settings';
|
|
27
|
-
import { findCurrency } from '../../libs/util';
|
|
28
27
|
import Collapse from '../collapse';
|
|
29
28
|
import CurrencySelect from './currency-select';
|
|
30
29
|
|
|
@@ -83,7 +82,7 @@ export default function PriceForm({ prefix, simple }: PriceFormProps) {
|
|
|
83
82
|
|
|
84
83
|
const { t } = useLocaleContext();
|
|
85
84
|
const { control, setValue, getFieldState } = useFormContext();
|
|
86
|
-
const { settings = {} as any, livemode } =
|
|
85
|
+
const { settings = {} as any, livemode } = usePaymentContext();
|
|
87
86
|
|
|
88
87
|
const currencies = useFieldArray({ control, name: getFieldName('currency_options') });
|
|
89
88
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
2
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
3
|
-
import
|
|
3
|
+
import { api, formatError, formatPrice } from '@blocklet/payment-react';
|
|
4
|
+
import type { TPriceExpanded } from '@blocklet/payment-types';
|
|
4
5
|
import { AddOutlined } from '@mui/icons-material';
|
|
5
6
|
import { Alert, CircularProgress, MenuItem, Select, Stack, Typography } from '@mui/material';
|
|
6
7
|
import { useRequest, useSetState } from 'ahooks';
|
|
7
8
|
|
|
8
|
-
import api from '../../libs/api';
|
|
9
|
-
import { formatError, formatPrice } from '../../libs/util';
|
|
10
9
|
import AddPrice from '../product/add-price';
|
|
11
10
|
|
|
12
11
|
type Props = {
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
2
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
3
|
-
import
|
|
3
|
+
import { api, formatError, formatPrice, usePaymentContext } from '@blocklet/payment-react';
|
|
4
|
+
import type { TPriceExpanded } from '@blocklet/payment-types';
|
|
4
5
|
import { DeleteOutlineOutlined } from '@mui/icons-material';
|
|
5
6
|
import { CircularProgress, Grid, IconButton, Stack, Typography } from '@mui/material';
|
|
6
7
|
import { useSetState } from 'ahooks';
|
|
7
8
|
|
|
8
|
-
import { useSettingsContext } from '../../contexts/settings';
|
|
9
|
-
import api from '../../libs/api';
|
|
10
|
-
import { formatError, formatPrice } from '../../libs/util';
|
|
11
9
|
import InfoRow from '../info-row';
|
|
12
10
|
import UpsellSelect from './upsell-select';
|
|
13
11
|
|
|
14
12
|
export function UpsellForm({ data, onChange }: { data: TPriceExpanded; onChange: Function }) {
|
|
15
|
-
const { settings } =
|
|
13
|
+
const { settings } = usePaymentContext();
|
|
16
14
|
const [state, setState] = useSetState({
|
|
17
15
|
loading: false,
|
|
18
16
|
});
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
2
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
3
|
-
import
|
|
3
|
+
import { api, formatError } from '@blocklet/payment-react';
|
|
4
|
+
import type { TPricingTableExpanded } from '@blocklet/payment-types';
|
|
4
5
|
import { useSetState } from 'ahooks';
|
|
5
6
|
import Copy from 'copy-to-clipboard';
|
|
6
7
|
import type { LiteralUnion } from 'type-fest';
|
|
7
8
|
import { joinURL } from 'ufo';
|
|
8
9
|
|
|
9
|
-
import api from '../../libs/api';
|
|
10
|
-
import { formatError } from '../../libs/util';
|
|
11
10
|
import Actions from '../actions';
|
|
12
11
|
import ClickBoundary from '../click-boundary';
|
|
13
12
|
import ConfirmDialog from '../confirm';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
2
|
import Tabs from '@arcblock/ux/lib/Tabs';
|
|
3
|
-
import
|
|
3
|
+
import { formatPrice, usePaymentContext } from '@blocklet/payment-react';
|
|
4
|
+
import type { TPrice, TProduct } from '@blocklet/payment-types';
|
|
4
5
|
import { Box, Checkbox, FormControlLabel, Stack, TextField, Typography } from '@mui/material';
|
|
5
6
|
import get from 'lodash/get';
|
|
6
7
|
import { useState } from 'react';
|
|
7
8
|
import { Controller, useFieldArray, useFormContext, useWatch } from 'react-hook-form';
|
|
8
9
|
|
|
9
10
|
import { useProductsContext } from '../../contexts/products';
|
|
10
|
-
import {
|
|
11
|
-
import { formatPrice, getPriceFromProducts, groupPricingTableItems } from '../../libs/util';
|
|
11
|
+
import { getPriceFromProducts, groupPricingTableItems } from '../../libs/util';
|
|
12
12
|
import IconCollapse from '../collapse';
|
|
13
13
|
|
|
14
14
|
export function PricePaymentSettings({ index }: { index: number }) {
|
|
@@ -173,7 +173,7 @@ export function PricePaymentSettings({ index }: { index: number }) {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
export function ProductPaymentSettings({ product, prices }: { product: TProduct; prices: TPrice[] }) {
|
|
176
|
-
const { settings } =
|
|
176
|
+
const { settings } = usePaymentContext();
|
|
177
177
|
const { products } = useProductsContext();
|
|
178
178
|
const [current, setCurrent] = useState(prices[0]?.id);
|
|
179
179
|
const tabs = prices.map((x: any) => ({
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
|
-
import
|
|
2
|
+
import { FormInput, formatPrice, usePaymentContext } from '@blocklet/payment-react';
|
|
3
|
+
import type { TPrice } from '@blocklet/payment-types';
|
|
3
4
|
import { DeleteOutlineOutlined } from '@mui/icons-material';
|
|
4
5
|
import { Box, Checkbox, FormControlLabel, IconButton, InputAdornment, Stack, Typography } from '@mui/material';
|
|
5
6
|
import { Controller, useFormContext, useWatch } from 'react-hook-form';
|
|
6
7
|
|
|
7
|
-
import { useSettingsContext } from '../../contexts/settings';
|
|
8
|
-
import { formatPrice } from '../../libs/util';
|
|
9
|
-
import FormInput from '../input';
|
|
10
|
-
|
|
11
8
|
type Props = {
|
|
12
9
|
prefix: string;
|
|
13
10
|
price: TPrice;
|
|
@@ -17,7 +14,7 @@ type Props = {
|
|
|
17
14
|
export default function PriceItem({ prefix, price, onRemove }: Props) {
|
|
18
15
|
const { t } = useLocaleContext();
|
|
19
16
|
const getFieldName = (name: string) => (prefix ? `${prefix}.${name}` : name);
|
|
20
|
-
const { settings } =
|
|
17
|
+
const { settings } = usePaymentContext();
|
|
21
18
|
const { control, setValue } = useFormContext();
|
|
22
19
|
const includeFreeTrail = useWatch({ control, name: getFieldName('include_free_trial') });
|
|
23
20
|
|
|
@@ -50,7 +47,7 @@ export default function PriceItem({ prefix, price, onRemove }: Props) {
|
|
|
50
47
|
{includeFreeTrail && (
|
|
51
48
|
<FormInput
|
|
52
49
|
name={getFieldName('subscription_data.trial_period_days')}
|
|
53
|
-
rules={{ required: t('checkout.required') }}
|
|
50
|
+
rules={{ required: t('payment.checkout.required') }}
|
|
54
51
|
errorPosition="right"
|
|
55
52
|
sx={{ mt: 0.5 }}
|
|
56
53
|
fullWidth={false}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
2
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
3
|
-
import
|
|
3
|
+
import { api, formatError } from '@blocklet/payment-react';
|
|
4
|
+
import type { PricingTableItem, TProduct, TProductExpanded } from '@blocklet/payment-types';
|
|
4
5
|
import { Box, Stack } from '@mui/material';
|
|
5
6
|
import { useSetState } from 'ahooks';
|
|
6
7
|
|
|
7
8
|
import { useProductsContext } from '../../contexts/products';
|
|
8
|
-
import
|
|
9
|
-
import { formatError, getPriceFromProducts } from '../../libs/util';
|
|
9
|
+
import { getPriceFromProducts } from '../../libs/util';
|
|
10
10
|
import Actions from '../actions';
|
|
11
11
|
import ClickBoundary from '../click-boundary';
|
|
12
12
|
import InfoCard from '../info-card';
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import Dialog from '@arcblock/ux/lib/Dialog';
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
-
import
|
|
3
|
+
import { FormInput } from '@blocklet/payment-react';
|
|
4
|
+
import type { TPricingTable } from '@blocklet/payment-types';
|
|
4
5
|
import { Button, CircularProgress, Stack } from '@mui/material';
|
|
5
6
|
import type { EventHandler } from 'react';
|
|
6
7
|
import { FormProvider, useForm } from 'react-hook-form';
|
|
7
8
|
|
|
8
|
-
import TextInput from '../input';
|
|
9
|
-
|
|
10
9
|
export default function RenamePricingTable({
|
|
11
10
|
data,
|
|
12
11
|
loading,
|
|
@@ -54,7 +53,7 @@ export default function RenamePricingTable({
|
|
|
54
53
|
</Stack>
|
|
55
54
|
}>
|
|
56
55
|
<FormProvider {...methods}>
|
|
57
|
-
<
|
|
56
|
+
<FormInput
|
|
58
57
|
name="name"
|
|
59
58
|
rules={{ required: true }}
|
|
60
59
|
label={t('admin.paymentLink.name.label')}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
2
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
3
|
-
import
|
|
3
|
+
import { api, formatError } from '@blocklet/payment-react';
|
|
4
|
+
import type { TProduct } from '@blocklet/payment-types';
|
|
4
5
|
import { useSetState } from 'ahooks';
|
|
5
6
|
import type { LiteralUnion } from 'type-fest';
|
|
6
7
|
|
|
7
|
-
import api from '../../libs/api';
|
|
8
|
-
import { formatError } from '../../libs/util';
|
|
9
8
|
import Actions from '../actions';
|
|
10
9
|
import ClickBoundary from '../click-boundary';
|
|
11
10
|
import ConfirmDialog from '../confirm';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Dialog from '@arcblock/ux/lib/Dialog';
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
+
import { usePaymentContext } from '@blocklet/payment-react';
|
|
3
4
|
import { Button, CircularProgress, Stack } from '@mui/material';
|
|
4
5
|
import type { EventHandler } from 'react';
|
|
5
6
|
import { FormProvider, useForm } from 'react-hook-form';
|
|
6
7
|
|
|
7
|
-
import { useSettingsContext } from '../../contexts/settings';
|
|
8
8
|
import PriceForm, { DEFAULT_PRICE, Price } from '../price/form';
|
|
9
9
|
|
|
10
10
|
export default function AddPrice({
|
|
@@ -17,7 +17,7 @@ export default function AddPrice({
|
|
|
17
17
|
onCancel: EventHandler<any>;
|
|
18
18
|
}) {
|
|
19
19
|
const { t } = useLocaleContext();
|
|
20
|
-
const { settings } =
|
|
20
|
+
const { settings } = usePaymentContext();
|
|
21
21
|
const methods = useForm<Price>({
|
|
22
22
|
defaultValues: {
|
|
23
23
|
...DEFAULT_PRICE,
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import Dialog from '@arcblock/ux/lib/Dialog';
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
3
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
4
|
+
import { api, formatError, usePaymentContext } from '@blocklet/payment-react';
|
|
4
5
|
import { Button, CircularProgress, Stack } from '@mui/material';
|
|
5
6
|
import { useSetState } from 'ahooks';
|
|
6
7
|
import type { EventHandler } from 'react';
|
|
7
8
|
import { FormProvider, useFieldArray, useForm } from 'react-hook-form';
|
|
8
9
|
|
|
9
|
-
import { useSettingsContext } from '../../contexts/settings';
|
|
10
|
-
import api from '../../libs/api';
|
|
11
|
-
import { formatError } from '../../libs/util';
|
|
12
10
|
import PriceForm, { DEFAULT_PRICE } from '../price/form';
|
|
13
11
|
import ProductForm, { Product } from './form';
|
|
14
12
|
|
|
@@ -22,7 +20,7 @@ export default function CreateProduct({
|
|
|
22
20
|
onCancel: EventHandler<any>;
|
|
23
21
|
}) {
|
|
24
22
|
const { t } = useLocaleContext();
|
|
25
|
-
const { settings } =
|
|
23
|
+
const { settings } = usePaymentContext();
|
|
26
24
|
const [state, setState] = useSetState({ loading: false });
|
|
27
25
|
const methods = useForm<Product>({
|
|
28
26
|
defaultValues: {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
|
-
import
|
|
2
|
+
import { usePaymentContext } from '@blocklet/payment-react';
|
|
3
|
+
import type { TProductExpanded } from '@blocklet/payment-types';
|
|
3
4
|
import { MenuItem, Select, Stack, Typography } from '@mui/material';
|
|
4
5
|
|
|
5
6
|
import { useProductsContext } from '../../contexts/products';
|
|
6
|
-
import { useSettingsContext } from '../../contexts/settings';
|
|
7
7
|
import { formatProductPrice } from '../../libs/util';
|
|
8
8
|
import InfoCard from '../info-card';
|
|
9
9
|
|
|
@@ -15,7 +15,7 @@ type Props = {
|
|
|
15
15
|
export default function CrossSellSelect({ data, onSelect }: Props) {
|
|
16
16
|
const { t, locale } = useLocaleContext();
|
|
17
17
|
const { products } = useProductsContext();
|
|
18
|
-
const { settings } =
|
|
18
|
+
const { settings } = usePaymentContext();
|
|
19
19
|
|
|
20
20
|
const onSelectPrice = (e: any) => {
|
|
21
21
|
if (e.target.value && e.target.value !== 'empty') {
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
2
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
3
|
-
import
|
|
3
|
+
import { api, formatError, usePaymentContext } from '@blocklet/payment-react';
|
|
4
|
+
import type { TProductExpanded } from '@blocklet/payment-types';
|
|
4
5
|
import { DeleteOutlineOutlined } from '@mui/icons-material';
|
|
5
6
|
import { CircularProgress, Grid, IconButton, Stack } from '@mui/material';
|
|
6
7
|
import { useSetState } from 'ahooks';
|
|
7
8
|
|
|
8
9
|
import { ProductsProvider } from '../../contexts/products';
|
|
9
|
-
import {
|
|
10
|
-
import api from '../../libs/api';
|
|
11
|
-
import { formatError, formatProductPrice } from '../../libs/util';
|
|
10
|
+
import { formatProductPrice } from '../../libs/util';
|
|
12
11
|
import InfoCard from '../info-card';
|
|
13
12
|
import InfoRow from '../info-row';
|
|
14
13
|
import CrossSellSelect from './cross-sell-select';
|
|
15
14
|
|
|
16
15
|
export function CrossSellForm({ data, onChange }: { data: TProductExpanded; onChange: Function }) {
|
|
17
16
|
const { locale } = useLocaleContext();
|
|
18
|
-
const { settings } =
|
|
17
|
+
const { settings } = usePaymentContext();
|
|
19
18
|
const [state, setState] = useSetState({
|
|
20
19
|
loading: false,
|
|
21
20
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/indent */
|
|
2
2
|
import Dialog from '@arcblock/ux/lib/Dialog';
|
|
3
3
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
4
|
-
import type { TProduct } from '@
|
|
4
|
+
import type { TProduct } from '@blocklet/payment-types';
|
|
5
5
|
import { Button, CircularProgress, Stack } from '@mui/material';
|
|
6
6
|
import { isEmpty } from 'lodash';
|
|
7
7
|
import type { EventHandler } from 'react';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
-
import
|
|
3
|
+
import { FormInput } from '@blocklet/payment-react';
|
|
4
|
+
import type { InferFormType, TProduct } from '@blocklet/payment-types';
|
|
4
5
|
import { Box, Stack, Typography } from '@mui/material';
|
|
5
6
|
import { useFormContext, useWatch } from 'react-hook-form';
|
|
6
7
|
|
|
7
8
|
import Collapse from '../collapse';
|
|
8
|
-
import TextInput from '../input';
|
|
9
9
|
import MetadataForm from '../metadata/form';
|
|
10
10
|
import type { Price } from '../price/form';
|
|
11
11
|
import Uploader from '../uploader';
|
|
@@ -32,7 +32,7 @@ export default function ProductForm(props: Props) {
|
|
|
32
32
|
return (
|
|
33
33
|
<Stack spacing={2} mb={3} direction="row" alignItems="flex-start">
|
|
34
34
|
<Stack spacing={2} flex={2} alignItems="flex-start">
|
|
35
|
-
<
|
|
35
|
+
<FormInput
|
|
36
36
|
name="name"
|
|
37
37
|
rules={{ required: t('admin.product.name.required') }}
|
|
38
38
|
label={t('admin.product.name.label')}
|
|
@@ -41,7 +41,7 @@ export default function ProductForm(props: Props) {
|
|
|
41
41
|
helperText={formState.errors.name?.message as string}
|
|
42
42
|
autoFocus
|
|
43
43
|
/>
|
|
44
|
-
<
|
|
44
|
+
<FormInput
|
|
45
45
|
name="description"
|
|
46
46
|
rules={{ required: t('admin.product.description.required') }}
|
|
47
47
|
label={t('admin.product.description.label')}
|
|
@@ -54,8 +54,8 @@ export default function ProductForm(props: Props) {
|
|
|
54
54
|
/>
|
|
55
55
|
<Collapse trigger={t('admin.product.additional')}>
|
|
56
56
|
<Stack spacing={2} alignItems="flex-start">
|
|
57
|
-
<
|
|
58
|
-
<
|
|
57
|
+
<FormInput name="statement_descriptor" label={t('admin.product.statement_descriptor.label')} />
|
|
58
|
+
<FormInput name="unit_label" label={t('admin.product.unit_label.label')} />
|
|
59
59
|
{!props.simple && <ProductFeatures />}
|
|
60
60
|
{!props.simple && <MetadataForm title={t('common.metadata.label')} />}
|
|
61
61
|
</Stack>
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
|
+
import { formatPrettyMsLocale, formatToDatetime } from '@blocklet/payment-react';
|
|
2
3
|
import { Tooltip, Typography } from '@mui/material';
|
|
3
4
|
import prettyMs from 'pretty-ms-i18n';
|
|
4
5
|
|
|
5
|
-
import { formatPrettyMsLocale, formatToDatetime } from '../libs/util';
|
|
6
|
-
|
|
7
6
|
export default function RelativeTime({ value, ...rest }: { value: string | number }) {
|
|
8
7
|
const { t, locale } = useLocaleContext();
|
|
9
8
|
if (!value) {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
|
-
import
|
|
2
|
+
import { formatTime } from '@blocklet/payment-react';
|
|
3
|
+
import type { TSubscriptionExpanded } from '@blocklet/payment-types';
|
|
3
4
|
import { Box, FormControlLabel, Radio, RadioGroup, Stack, TextField, Typography } from '@mui/material';
|
|
4
5
|
import { Controller, useFormContext, useWatch } from 'react-hook-form';
|
|
5
6
|
|
|
6
|
-
import { formatTime } from '../../../libs/util';
|
|
7
|
-
|
|
8
7
|
export default function SubscriptionCancelForm({ data }: { data: TSubscriptionExpanded }) {
|
|
9
8
|
const { t } = useLocaleContext();
|
|
10
9
|
const { control, setValue, formState } = useFormContext();
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
2
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
3
|
-
import
|
|
3
|
+
import { api, formatError } from '@blocklet/payment-react';
|
|
4
|
+
import type { TSubscriptionExpanded } from '@blocklet/payment-types';
|
|
4
5
|
import { useSetState } from 'ahooks';
|
|
5
6
|
import { FormProvider, useForm, useFormContext } from 'react-hook-form';
|
|
6
7
|
import { useNavigate } from 'react-router-dom';
|
|
7
8
|
import type { LiteralUnion } from 'type-fest';
|
|
8
9
|
|
|
9
|
-
import api from '../../../libs/api';
|
|
10
|
-
import { formatError } from '../../../libs/util';
|
|
11
10
|
import Actions from '../../actions';
|
|
12
11
|
import ClickBoundary from '../../click-boundary';
|
|
13
12
|
import ConfirmDialog from '../../confirm';
|