payment-kit 1.18.12 → 1.18.14
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/index.ts +2 -0
- package/api/src/integrations/stripe/resource.ts +53 -11
- package/api/src/libs/auth.ts +14 -0
- package/api/src/libs/notification/template/one-time-payment-succeeded.ts +5 -3
- package/api/src/libs/notification/template/subscription-canceled.ts +3 -3
- package/api/src/libs/notification/template/subscription-refund-succeeded.ts +4 -3
- package/api/src/libs/notification/template/subscription-renew-failed.ts +5 -4
- package/api/src/libs/notification/template/subscription-renewed.ts +2 -1
- package/api/src/libs/notification/template/subscription-stake-slash-succeeded.ts +3 -4
- package/api/src/libs/notification/template/subscription-succeeded.ts +2 -1
- package/api/src/libs/notification/template/subscription-upgraded.ts +6 -4
- package/api/src/libs/notification/template/subscription-will-canceled.ts +6 -3
- package/api/src/libs/notification/template/subscription-will-renew.ts +1 -1
- package/api/src/libs/payment.ts +77 -2
- package/api/src/libs/util.ts +8 -0
- package/api/src/queues/payment.ts +50 -1
- package/api/src/queues/payout.ts +297 -0
- package/api/src/routes/checkout-sessions.ts +2 -7
- package/api/src/routes/customers.ts +79 -5
- package/api/src/routes/payment-currencies.ts +117 -1
- package/api/src/routes/payment-methods.ts +19 -9
- package/api/src/routes/subscriptions.ts +15 -9
- package/api/src/store/migrations/20250305-vault-config.ts +21 -0
- package/api/src/store/models/invoice.ts +4 -2
- package/api/src/store/models/payment-currency.ts +14 -0
- package/api/src/store/models/payout.ts +21 -0
- package/api/src/store/models/types.ts +6 -0
- package/blocklet.yml +2 -2
- package/package.json +18 -18
- package/src/app.tsx +117 -121
- package/src/components/actions.tsx +32 -9
- package/src/components/copyable.tsx +2 -2
- package/src/components/customer/overdraft-protection.tsx +1 -0
- package/src/components/layout/admin.tsx +6 -0
- package/src/components/layout/user.tsx +38 -0
- package/src/components/metadata/editor.tsx +7 -1
- package/src/components/metadata/list.tsx +3 -0
- package/src/components/passport/assign.tsx +3 -0
- package/src/components/payment-link/rename.tsx +1 -0
- package/src/components/pricing-table/rename.tsx +1 -0
- package/src/components/product/add-price.tsx +1 -0
- package/src/components/product/edit-price.tsx +1 -0
- package/src/components/product/edit.tsx +1 -0
- package/src/components/subscription/actions/index.tsx +1 -0
- package/src/components/subscription/portal/actions.tsx +27 -5
- package/src/components/subscription/portal/list.tsx +24 -6
- package/src/components/subscription/status.tsx +2 -2
- package/src/libs/util.ts +15 -0
- package/src/locales/en.tsx +42 -0
- package/src/locales/zh.tsx +37 -0
- package/src/pages/admin/payments/payouts/detail.tsx +47 -38
- package/src/pages/admin/settings/index.tsx +3 -3
- package/src/pages/admin/settings/payment-methods/index.tsx +33 -1
- package/src/pages/admin/settings/vault-config/edit-form.tsx +253 -0
- package/src/pages/admin/settings/vault-config/index.tsx +352 -0
- package/src/pages/customer/index.tsx +247 -154
- package/src/pages/customer/invoice/detail.tsx +1 -1
- package/src/pages/customer/payout/detail.tsx +9 -2
- package/src/pages/customer/recharge.tsx +6 -2
- package/src/pages/customer/subscription/change-payment.tsx +1 -1
- package/src/pages/customer/subscription/change-plan.tsx +1 -1
- package/src/pages/customer/subscription/detail.tsx +8 -3
- package/src/pages/customer/subscription/embed.tsx +142 -84
- package/src/pages/integrations/donations/edit-form.tsx +0 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DataTypes } from 'sequelize';
|
|
2
|
+
|
|
3
|
+
import { Migration, safeApplyColumnChanges } from '../migrate';
|
|
4
|
+
|
|
5
|
+
export const up: Migration = async ({ context }) => {
|
|
6
|
+
await safeApplyColumnChanges(context, {
|
|
7
|
+
payment_currencies: [
|
|
8
|
+
{
|
|
9
|
+
name: 'vault_config',
|
|
10
|
+
field: {
|
|
11
|
+
type: DataTypes.JSON,
|
|
12
|
+
allowNull: true,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const down: Migration = async ({ context }) => {
|
|
20
|
+
await context.removeColumn('payment_currencies', 'vault_config');
|
|
21
|
+
};
|
|
@@ -530,7 +530,9 @@ export class Invoice extends Model<InferAttributes<Invoice>, InferCreationAttrib
|
|
|
530
530
|
return ['paid', 'void'].includes(this.status);
|
|
531
531
|
}
|
|
532
532
|
|
|
533
|
-
private static async _getUncollectibleAmount(
|
|
533
|
+
private static async _getUncollectibleAmount(
|
|
534
|
+
where: WhereOptions<Invoice>
|
|
535
|
+
): Promise<[GroupedBN, GroupedStrList, Invoice[]]> {
|
|
534
536
|
const invoices = await Invoice.findAll({ where });
|
|
535
537
|
const summary: GroupedBN = {};
|
|
536
538
|
const detail: GroupedStrList = {};
|
|
@@ -548,7 +550,7 @@ export class Invoice extends Model<InferAttributes<Invoice>, InferCreationAttrib
|
|
|
548
550
|
detail[key]!.push(invoice.id);
|
|
549
551
|
});
|
|
550
552
|
|
|
551
|
-
return [summary, detail];
|
|
553
|
+
return [summary, detail, invoices];
|
|
552
554
|
}
|
|
553
555
|
|
|
554
556
|
public static getUncollectibleAmount({
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from 'sequelize';
|
|
12
12
|
|
|
13
13
|
import { createIdGenerator } from '../../libs/util';
|
|
14
|
+
import { VaultConfig } from './types';
|
|
14
15
|
|
|
15
16
|
const nextId = createIdGenerator('pc', 12);
|
|
16
17
|
|
|
@@ -41,6 +42,7 @@ export class PaymentCurrency extends Model<InferAttributes<PaymentCurrency>, Inf
|
|
|
41
42
|
|
|
42
43
|
declare created_at: CreationOptional<Date>;
|
|
43
44
|
declare updated_at: CreationOptional<Date>;
|
|
45
|
+
declare vault_config?: VaultConfig;
|
|
44
46
|
|
|
45
47
|
public static readonly GENESIS_ATTRIBUTES = {
|
|
46
48
|
id: {
|
|
@@ -120,6 +122,10 @@ export class PaymentCurrency extends Model<InferAttributes<PaymentCurrency>, Inf
|
|
|
120
122
|
defaultValue: DataTypes.NOW,
|
|
121
123
|
allowNull: false,
|
|
122
124
|
},
|
|
125
|
+
vault_config: {
|
|
126
|
+
type: DataTypes.JSON,
|
|
127
|
+
allowNull: true,
|
|
128
|
+
},
|
|
123
129
|
};
|
|
124
130
|
|
|
125
131
|
public static initialize(sequelize: any) {
|
|
@@ -129,6 +135,14 @@ export class PaymentCurrency extends Model<InferAttributes<PaymentCurrency>, Inf
|
|
|
129
135
|
tableName: 'payment_currencies',
|
|
130
136
|
createdAt: 'created_at',
|
|
131
137
|
updatedAt: 'updated_at',
|
|
138
|
+
defaultScope: {
|
|
139
|
+
attributes: { exclude: ['vault_config'] },
|
|
140
|
+
},
|
|
141
|
+
scopes: {
|
|
142
|
+
withVaultConfig: {
|
|
143
|
+
attributes: { include: ['vault_config'] },
|
|
144
|
+
},
|
|
145
|
+
},
|
|
132
146
|
});
|
|
133
147
|
}
|
|
134
148
|
|
|
@@ -251,6 +251,27 @@ export class Payout extends Model<InferAttributes<Payout>, InferCreationAttribut
|
|
|
251
251
|
raw: true,
|
|
252
252
|
}).then((res) => res.rows);
|
|
253
253
|
}
|
|
254
|
+
|
|
255
|
+
public static async getPayoutLockedAmount(where?: any) {
|
|
256
|
+
const payouts = await Payout.findAll({
|
|
257
|
+
where: {
|
|
258
|
+
status: {
|
|
259
|
+
[Op.in]: ['pending', 'in_transit'],
|
|
260
|
+
},
|
|
261
|
+
...(where || {}),
|
|
262
|
+
},
|
|
263
|
+
attributes: ['amount'],
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
return payouts.reduce((acc: GroupedBN, payout) => {
|
|
267
|
+
const key = payout.currency_id;
|
|
268
|
+
if (!acc[key]) {
|
|
269
|
+
acc[key] = '0';
|
|
270
|
+
}
|
|
271
|
+
acc[key] = new BN(acc[key]).add(new BN(payout.amount)).toString();
|
|
272
|
+
return acc;
|
|
273
|
+
}, {});
|
|
274
|
+
}
|
|
254
275
|
}
|
|
255
276
|
|
|
256
277
|
export type TPayout = InferAttributes<Payout>;
|
|
@@ -290,6 +290,12 @@ export type PaymentMethodSettings = {
|
|
|
290
290
|
};
|
|
291
291
|
};
|
|
292
292
|
|
|
293
|
+
export type VaultConfig = {
|
|
294
|
+
enabled: boolean;
|
|
295
|
+
deposit_threshold: string; // 存入阈值
|
|
296
|
+
withdraw_threshold: string; // 提取阈值
|
|
297
|
+
};
|
|
298
|
+
|
|
293
299
|
export type PaymentSettings = {
|
|
294
300
|
payment_method_options: PaymentMethodOptions;
|
|
295
301
|
payment_method_types: string[];
|
package/blocklet.yml
CHANGED
|
@@ -14,7 +14,7 @@ repository:
|
|
|
14
14
|
type: git
|
|
15
15
|
url: git+https://github.com/blocklet/payment-kit.git
|
|
16
16
|
specVersion: 1.2.8
|
|
17
|
-
version: 1.18.
|
|
17
|
+
version: 1.18.14
|
|
18
18
|
logo: logo.png
|
|
19
19
|
files:
|
|
20
20
|
- dist
|
|
@@ -113,7 +113,7 @@ navigation:
|
|
|
113
113
|
icon: ion:receipt-outline
|
|
114
114
|
link: /customer
|
|
115
115
|
section:
|
|
116
|
-
-
|
|
116
|
+
- userCenter
|
|
117
117
|
- sessionManager
|
|
118
118
|
role:
|
|
119
119
|
- owner
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payment-kit",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.14",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev --open",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -44,29 +44,29 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@abtnode/cron": "^1.16.39",
|
|
47
|
-
"@arcblock/did": "^1.19.
|
|
47
|
+
"@arcblock/did": "^1.19.15",
|
|
48
48
|
"@arcblock/did-auth-storage-nedb": "^1.7.1",
|
|
49
|
-
"@arcblock/did-connect": "^2.
|
|
50
|
-
"@arcblock/did-util": "^1.19.
|
|
51
|
-
"@arcblock/jwt": "^1.19.
|
|
52
|
-
"@arcblock/ux": "^2.
|
|
53
|
-
"@arcblock/validator": "^1.19.
|
|
49
|
+
"@arcblock/did-connect": "^2.12.12",
|
|
50
|
+
"@arcblock/did-util": "^1.19.15",
|
|
51
|
+
"@arcblock/jwt": "^1.19.15",
|
|
52
|
+
"@arcblock/ux": "^2.12.12",
|
|
53
|
+
"@arcblock/validator": "^1.19.15",
|
|
54
54
|
"@blocklet/js-sdk": "^1.16.39",
|
|
55
55
|
"@blocklet/logger": "^1.16.39",
|
|
56
|
-
"@blocklet/payment-react": "1.18.
|
|
56
|
+
"@blocklet/payment-react": "1.18.14",
|
|
57
57
|
"@blocklet/sdk": "^1.16.39",
|
|
58
|
-
"@blocklet/ui-react": "^2.
|
|
58
|
+
"@blocklet/ui-react": "^2.12.12",
|
|
59
59
|
"@blocklet/uploader": "^0.1.71",
|
|
60
60
|
"@blocklet/xss": "^0.1.27",
|
|
61
61
|
"@mui/icons-material": "^5.16.6",
|
|
62
62
|
"@mui/lab": "^5.0.0-alpha.173",
|
|
63
63
|
"@mui/material": "^5.16.6",
|
|
64
64
|
"@mui/system": "^5.16.6",
|
|
65
|
-
"@ocap/asset": "^1.19.
|
|
66
|
-
"@ocap/client": "^1.19.
|
|
67
|
-
"@ocap/mcrypto": "^1.19.
|
|
68
|
-
"@ocap/util": "^1.19.
|
|
69
|
-
"@ocap/wallet": "^1.19.
|
|
65
|
+
"@ocap/asset": "^1.19.15",
|
|
66
|
+
"@ocap/client": "^1.19.15",
|
|
67
|
+
"@ocap/mcrypto": "^1.19.15",
|
|
68
|
+
"@ocap/util": "^1.19.15",
|
|
69
|
+
"@ocap/wallet": "^1.19.15",
|
|
70
70
|
"@stripe/react-stripe-js": "^2.7.3",
|
|
71
71
|
"@stripe/stripe-js": "^2.4.0",
|
|
72
72
|
"ahooks": "^3.8.0",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"dayjs": "^1.11.12",
|
|
81
81
|
"debug": "^4.3.6",
|
|
82
82
|
"dotenv-flow": "^3.3.0",
|
|
83
|
-
"ethers": "^6.13.
|
|
83
|
+
"ethers": "^6.13.5",
|
|
84
84
|
"express": "^4.19.2",
|
|
85
85
|
"express-async-errors": "^3.1.1",
|
|
86
86
|
"express-history-api-fallback": "^2.2.1",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"devDependencies": {
|
|
122
122
|
"@abtnode/types": "^1.16.39",
|
|
123
123
|
"@arcblock/eslint-config-ts": "^0.3.3",
|
|
124
|
-
"@blocklet/payment-types": "1.18.
|
|
124
|
+
"@blocklet/payment-types": "1.18.14",
|
|
125
125
|
"@types/cookie-parser": "^1.4.7",
|
|
126
126
|
"@types/cors": "^2.8.17",
|
|
127
127
|
"@types/debug": "^4.1.12",
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
"vite": "^5.3.5",
|
|
152
152
|
"vite-node": "^2.0.4",
|
|
153
153
|
"vite-plugin-babel-import": "^2.0.5",
|
|
154
|
-
"vite-plugin-blocklet": "^0.9.
|
|
154
|
+
"vite-plugin-blocklet": "^0.9.23",
|
|
155
155
|
"vite-plugin-node-polyfills": "^0.21.0",
|
|
156
156
|
"vite-plugin-svgr": "^4.2.0",
|
|
157
157
|
"vite-tsconfig-paths": "^4.3.2",
|
|
@@ -167,5 +167,5 @@
|
|
|
167
167
|
"parser": "typescript"
|
|
168
168
|
}
|
|
169
169
|
},
|
|
170
|
-
"gitHead": "
|
|
170
|
+
"gitHead": "84cf68d98fcf1df0655e90567b98d6bab38f300e"
|
|
171
171
|
}
|
package/src/app.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import { Navigate, Route, BrowserRouter as Router, Routes } from 'react-router-d
|
|
|
13
13
|
import { joinURL } from 'ufo';
|
|
14
14
|
|
|
15
15
|
import ErrorFallback from './components/error-fallback';
|
|
16
|
-
import
|
|
16
|
+
import UserLayout from './components/layout/user';
|
|
17
17
|
import { TransitionProvider } from './components/progress-bar';
|
|
18
18
|
import { SessionProvider } from './contexts/session';
|
|
19
19
|
import { translations } from './locales';
|
|
@@ -43,119 +43,113 @@ const IntegrationsPage = React.lazy(() => import('./pages/integrations'));
|
|
|
43
43
|
|
|
44
44
|
function App() {
|
|
45
45
|
return (
|
|
46
|
-
<
|
|
47
|
-
<
|
|
48
|
-
<
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
/>
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
</Routes>
|
|
154
|
-
</Suspense>
|
|
155
|
-
</ErrorBoundary>
|
|
156
|
-
</LocaleProvider>
|
|
157
|
-
</TransitionProvider>
|
|
158
|
-
</PaymentThemeProvider>
|
|
46
|
+
<TransitionProvider>
|
|
47
|
+
<LocaleProvider translations={translations} fallbackLocale="en">
|
|
48
|
+
<ErrorBoundary FallbackComponent={ErrorFallback} onReset={window.location.reload}>
|
|
49
|
+
<Suspense
|
|
50
|
+
fallback={
|
|
51
|
+
<Center>
|
|
52
|
+
<CircularProgress />
|
|
53
|
+
</Center>
|
|
54
|
+
}>
|
|
55
|
+
<Routes>
|
|
56
|
+
<Route path="/" element={<HomePage />} />
|
|
57
|
+
<Route path="/checkout/:action/:id" element={<CheckoutPage />} />
|
|
58
|
+
<Route key="admin-index" path="/admin" element={<AdminPage />} />,
|
|
59
|
+
<Route key="admin-tabs" path="/admin/:group" element={<AdminPage />} />,
|
|
60
|
+
<Route key="admin-sub" path="/admin/:group/:page" element={<AdminPage />} />,
|
|
61
|
+
<Route key="admin-fallback" path="/admin/*" element={<AdminPage />} />,
|
|
62
|
+
<Route key="integrations-index" path="/integrations" element={<IntegrationsPage />} />
|
|
63
|
+
<Route key="integrations-tabs" path="/integrations/:group" element={<IntegrationsPage />} />
|
|
64
|
+
<Route key="integrations-sub" path="/integrations/:group/:page" element={<IntegrationsPage />} />
|
|
65
|
+
<Route key="integrations-fallback" path="/integrations/*" element={<IntegrationsPage />} />
|
|
66
|
+
<Route
|
|
67
|
+
key="customer-home"
|
|
68
|
+
path="/customer"
|
|
69
|
+
element={
|
|
70
|
+
<UserLayout>
|
|
71
|
+
<CustomerHome />
|
|
72
|
+
</UserLayout>
|
|
73
|
+
}
|
|
74
|
+
/>
|
|
75
|
+
<Route
|
|
76
|
+
key="customer-subscription"
|
|
77
|
+
path="/customer/subscription/:id"
|
|
78
|
+
element={
|
|
79
|
+
<UserLayout>
|
|
80
|
+
<CustomerSubscriptionDetail />
|
|
81
|
+
</UserLayout>
|
|
82
|
+
}
|
|
83
|
+
/>
|
|
84
|
+
<Route
|
|
85
|
+
key="customer-subscription-change-plan"
|
|
86
|
+
path="/customer/subscription/:id/change-plan"
|
|
87
|
+
element={
|
|
88
|
+
<UserLayout>
|
|
89
|
+
<CustomerSubscriptionChangePlan />
|
|
90
|
+
</UserLayout>
|
|
91
|
+
}
|
|
92
|
+
/>
|
|
93
|
+
<Route
|
|
94
|
+
key="customer-subscription-change-payment"
|
|
95
|
+
path="/customer/subscription/:id/change-payment"
|
|
96
|
+
element={
|
|
97
|
+
<UserLayout>
|
|
98
|
+
<CustomerSubscriptionChangePayment />
|
|
99
|
+
</UserLayout>
|
|
100
|
+
}
|
|
101
|
+
/>
|
|
102
|
+
<Route
|
|
103
|
+
key="customer-recharge"
|
|
104
|
+
path="/customer/subscription/:id/recharge"
|
|
105
|
+
element={
|
|
106
|
+
<UserLayout>
|
|
107
|
+
<CustomerRecharge />
|
|
108
|
+
</UserLayout>
|
|
109
|
+
}
|
|
110
|
+
/>
|
|
111
|
+
<Route key="customer-embed" path="/customer/embed/subscription" element={<CustomerSubscriptionEmbed />} />
|
|
112
|
+
,
|
|
113
|
+
<Route
|
|
114
|
+
key="subscription-embed"
|
|
115
|
+
path="/embed/customer/subscription"
|
|
116
|
+
element={<CustomerSubscriptionEmbed />}
|
|
117
|
+
/>
|
|
118
|
+
,
|
|
119
|
+
<Route
|
|
120
|
+
key="customer-due"
|
|
121
|
+
path="/customer/invoice/past-due"
|
|
122
|
+
element={
|
|
123
|
+
<UserLayout>
|
|
124
|
+
<CustomerInvoicePastDue />
|
|
125
|
+
</UserLayout>
|
|
126
|
+
}
|
|
127
|
+
/>
|
|
128
|
+
<Route
|
|
129
|
+
key="customer-invoice"
|
|
130
|
+
path="/customer/invoice/:id"
|
|
131
|
+
element={
|
|
132
|
+
<UserLayout>
|
|
133
|
+
<CustomerInvoiceDetail />
|
|
134
|
+
</UserLayout>
|
|
135
|
+
}
|
|
136
|
+
/>
|
|
137
|
+
<Route
|
|
138
|
+
key="customer-payout"
|
|
139
|
+
path="/customer/payout/:id"
|
|
140
|
+
element={
|
|
141
|
+
<UserLayout>
|
|
142
|
+
<CustomerPayoutDetail />
|
|
143
|
+
</UserLayout>
|
|
144
|
+
}
|
|
145
|
+
/>
|
|
146
|
+
<Route key="customer-fallback" path="/customer/*" element={<Navigate to="/customer" />} />,
|
|
147
|
+
<Route path="*" element={<Navigate to="/" />} />
|
|
148
|
+
</Routes>
|
|
149
|
+
</Suspense>
|
|
150
|
+
</ErrorBoundary>
|
|
151
|
+
</LocaleProvider>
|
|
152
|
+
</TransitionProvider>
|
|
159
153
|
);
|
|
160
154
|
}
|
|
161
155
|
|
|
@@ -169,13 +163,15 @@ export default function WrappedApp() {
|
|
|
169
163
|
|
|
170
164
|
return (
|
|
171
165
|
<ToastProvider>
|
|
172
|
-
<
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
<
|
|
177
|
-
|
|
178
|
-
|
|
166
|
+
<PaymentThemeProvider>
|
|
167
|
+
<SessionProvider
|
|
168
|
+
serviceHost={prefix}
|
|
169
|
+
protectedRoutes={['/admin/*', '/customer/*', '/integrations/*'].map((item) => joinURL(prefix, item))}>
|
|
170
|
+
<Router basename={prefix}>
|
|
171
|
+
<AppWithTracker />
|
|
172
|
+
</Router>
|
|
173
|
+
</SessionProvider>
|
|
174
|
+
</PaymentThemeProvider>
|
|
179
175
|
</ToastProvider>
|
|
180
176
|
);
|
|
181
177
|
}
|
|
@@ -16,7 +16,7 @@ type ActionItem = {
|
|
|
16
16
|
|
|
17
17
|
export type ActionsProps = {
|
|
18
18
|
actions: ActionItem[];
|
|
19
|
-
variant?: LiteralUnion<'compact' | 'normal', string>;
|
|
19
|
+
variant?: LiteralUnion<'compact' | 'normal' | 'outlined', string>;
|
|
20
20
|
sx?: any;
|
|
21
21
|
onOpenCallback?: Function;
|
|
22
22
|
};
|
|
@@ -58,17 +58,40 @@ export default function Actions(props: ActionsProps) {
|
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
const renderButton = () => {
|
|
62
|
+
if (props.variant === 'outlined') {
|
|
63
|
+
return (
|
|
64
|
+
<Button
|
|
65
|
+
aria-label="actions"
|
|
66
|
+
sx={{
|
|
67
|
+
minWidth: 0,
|
|
68
|
+
padding: '5px',
|
|
69
|
+
...props.sx,
|
|
70
|
+
}}
|
|
71
|
+
variant="outlined"
|
|
72
|
+
onClick={onOpen}
|
|
73
|
+
size="small">
|
|
74
|
+
<MoreHorizOutlined />
|
|
75
|
+
</Button>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
if (props.variant === 'compact') {
|
|
79
|
+
return (
|
|
64
80
|
<IconButton aria-label="actions" sx={props.sx} aria-haspopup="true" onClick={onOpen} size="small">
|
|
65
81
|
<MoreHorizOutlined />
|
|
66
82
|
</IconButton>
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return (
|
|
86
|
+
<Button sx={props.sx} onClick={onOpen} size="small" variant="contained" color="primary">
|
|
87
|
+
{t('common.actions')} <ExpandMoreOutlined fontSize="small" />
|
|
88
|
+
</Button>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<>
|
|
94
|
+
{renderButton()}
|
|
72
95
|
<Menu
|
|
73
96
|
anchorEl={anchorEl}
|
|
74
97
|
open={open}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CopyButton } from '@arcblock/ux/lib/ClickToCopy';
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
3
|
import { getWordBreakStyle } from '@blocklet/payment-react';
|
|
4
|
-
import {
|
|
4
|
+
import { Stack, Typography } from '@mui/material';
|
|
5
5
|
import type { ReactNode } from 'react';
|
|
6
6
|
|
|
7
7
|
interface CopyableProps {
|
|
@@ -35,7 +35,7 @@ export default function Copyable({ text, children, style }: CopyableProps) {
|
|
|
35
35
|
{text}
|
|
36
36
|
</Typography>
|
|
37
37
|
)}
|
|
38
|
-
<
|
|
38
|
+
<Typography sx={{ display: 'inline-flex', '> span': { display: 'inline-flex' } }}>{copyButton}</Typography>
|
|
39
39
|
</Stack>
|
|
40
40
|
)}
|
|
41
41
|
/>
|
|
@@ -22,6 +22,12 @@ const Root = styled(Dashboard)<{ padding: string }>`
|
|
|
22
22
|
min-width: auto;
|
|
23
23
|
font-size: 0.875rem;
|
|
24
24
|
}
|
|
25
|
+
.page-content .MuiTab-root {
|
|
26
|
+
font-size: 0.875rem;
|
|
27
|
+
&.Mui-selected {
|
|
28
|
+
font-size: 1.125rem;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
25
31
|
|
|
26
32
|
.MuiTabs-root {
|
|
27
33
|
min-height: 32px;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
+
import { PaymentProvider } from '@blocklet/payment-react';
|
|
3
|
+
import { UserCenter } from '@blocklet/ui-react';
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
|
|
6
|
+
import { useSessionContext } from '../../contexts/session';
|
|
7
|
+
|
|
8
|
+
export default function UserLayout(props: any) {
|
|
9
|
+
const { session, connectApi, events } = useSessionContext();
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
events.once('logout', () => {
|
|
13
|
+
window.location.href = `${window.location.origin}/.well-known/service/user`;
|
|
14
|
+
});
|
|
15
|
+
}, []);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (session.initialized && !session.user) {
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
session.login(() => {}, { openMode: 'redirect', redirect: window.location.href });
|
|
21
|
+
}
|
|
22
|
+
}, [session.initialized]);
|
|
23
|
+
|
|
24
|
+
if (session.user) {
|
|
25
|
+
return (
|
|
26
|
+
<PaymentProvider session={session} connect={connectApi}>
|
|
27
|
+
<UserCenter
|
|
28
|
+
currentTab={`${window.blocklet.prefix}customer`}
|
|
29
|
+
userDid={session.user.did}
|
|
30
|
+
hideFooter
|
|
31
|
+
notLoginContent="undefined">
|
|
32
|
+
{props.children}
|
|
33
|
+
</UserCenter>
|
|
34
|
+
</PaymentProvider>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
@@ -57,7 +57,13 @@ export default function MetadataEditor({
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
return (
|
|
60
|
-
<Dialog
|
|
60
|
+
<Dialog
|
|
61
|
+
open
|
|
62
|
+
disableEscapeKeyDown
|
|
63
|
+
fullWidth
|
|
64
|
+
onClose={() => onCancel(null)}
|
|
65
|
+
title={t('common.metadata.edit')}
|
|
66
|
+
className="base-dialog">
|
|
61
67
|
<FormProvider {...methods}>
|
|
62
68
|
<MetadataForm
|
|
63
69
|
actions={
|