@blocklet/aigne-hub 0.2.20 → 0.2.21
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.
|
@@ -13,11 +13,11 @@ const ahooks_1 = require("ahooks");
|
|
|
13
13
|
const user_1 = require("../api/user");
|
|
14
14
|
const util_1 = require("../utils/util");
|
|
15
15
|
const withLocaleProvider_1 = __importDefault(require("../utils/withLocaleProvider"));
|
|
16
|
-
function UserCreditCard({ baseUrl,
|
|
17
|
-
var _a, _b
|
|
16
|
+
function UserCreditCard({ baseUrl, apiKey, onSuccess = () => { }, onError = () => { }, mode = 'default', render = () => null, chargeBtnProps = {}, manageBtnProps = {}, }) {
|
|
17
|
+
var _a, _b;
|
|
18
18
|
const { t } = (0, context_1.useLocaleContext)();
|
|
19
|
-
const { data: userInfoData, loading } = (0, ahooks_1.useRequest)(() => (0, user_1.getUserInfo)({ baseUrl, accessKey }), {
|
|
20
|
-
refreshDeps: [baseUrl,
|
|
19
|
+
const { data: userInfoData, loading } = (0, ahooks_1.useRequest)(() => (0, user_1.getUserInfo)({ baseUrl, accessKey: apiKey }), {
|
|
20
|
+
refreshDeps: [baseUrl, apiKey],
|
|
21
21
|
onError: (err) => {
|
|
22
22
|
Toast_1.default.error((0, error_1.formatError)(err));
|
|
23
23
|
onError === null || onError === void 0 ? void 0 : onError(err);
|
|
@@ -41,16 +41,16 @@ function UserCreditCard({ baseUrl, accessKey, onSuccess = () => { }, onError = (
|
|
|
41
41
|
minWidth: 0,
|
|
42
42
|
}, avatarProps: {
|
|
43
43
|
size: 24,
|
|
44
|
-
} })] }), (userInfoData === null || userInfoData === void 0 ? void 0 : userInfoData.enableCredit) ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: t('creditBalance') }), (0, jsx_runtime_1.
|
|
44
|
+
} })] }), (userInfoData === null || userInfoData === void 0 ? void 0 : userInfoData.enableCredit) ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: t('creditBalance') }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", fontWeight: "bold", children: (0, util_1.formatNumber)(((_a = userInfoData === null || userInfoData === void 0 ? void 0 : userInfoData.creditBalance) === null || _a === void 0 ? void 0 : _a.balance) || '0') })] }), ((_b = userInfoData.creditBalance) === null || _b === void 0 ? void 0 : _b.pendingCredit) && Number(userInfoData.creditBalance.pendingCredit) > 0 && ((0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", children: t('pendingCredit') }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", fontWeight: "bold", sx: { color: 'error.main' }, children: (0, util_1.formatNumber)(userInfoData.creditBalance.pendingCredit) })] })), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 1.5, sx: { mt: 1 }, className: "user-credit-card-actions", children: [(userInfoData === null || userInfoData === void 0 ? void 0 : userInfoData.paymentLink) && ((0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", className: "recharge-button", onClick: () => {
|
|
45
45
|
window.open((userInfoData === null || userInfoData === void 0 ? void 0 : userInfoData.paymentLink) || '', '_blank');
|
|
46
46
|
}, sx: {
|
|
47
47
|
flex: 1,
|
|
48
|
-
}, children: t('recharge') })), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", onClick: () => {
|
|
48
|
+
}, ...chargeBtnProps, children: t('recharge') })), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "text", className: "manage-button", onClick: () => {
|
|
49
49
|
window.open((userInfoData === null || userInfoData === void 0 ? void 0 : userInfoData.profileLink) || '', '_blank');
|
|
50
50
|
}, sx: {
|
|
51
51
|
borderColor: 'primary.main',
|
|
52
52
|
color: 'primary.main',
|
|
53
|
-
}, children: t('manage') })] })] })) : ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "info", sx: {
|
|
53
|
+
}, ...manageBtnProps, children: t('manage') })] })] })) : ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "info", sx: {
|
|
54
54
|
textAlign: 'left',
|
|
55
55
|
}, children: [t('creditNotEnabled'), (0, jsx_runtime_1.jsx)(material_1.Typography, { sx: {
|
|
56
56
|
display: 'inline-block',
|
|
@@ -8,11 +8,11 @@ import { useRequest } from 'ahooks';
|
|
|
8
8
|
import { getUserInfo } from '../api/user';
|
|
9
9
|
import { formatNumber } from '../utils/util';
|
|
10
10
|
import withLocaleProvider from '../utils/withLocaleProvider';
|
|
11
|
-
function UserCreditCard({ baseUrl,
|
|
12
|
-
var _a, _b
|
|
11
|
+
function UserCreditCard({ baseUrl, apiKey, onSuccess = () => { }, onError = () => { }, mode = 'default', render = () => null, chargeBtnProps = {}, manageBtnProps = {}, }) {
|
|
12
|
+
var _a, _b;
|
|
13
13
|
const { t } = useLocaleContext();
|
|
14
|
-
const { data: userInfoData, loading } = useRequest(() => getUserInfo({ baseUrl, accessKey }), {
|
|
15
|
-
refreshDeps: [baseUrl,
|
|
14
|
+
const { data: userInfoData, loading } = useRequest(() => getUserInfo({ baseUrl, accessKey: apiKey }), {
|
|
15
|
+
refreshDeps: [baseUrl, apiKey],
|
|
16
16
|
onError: (err) => {
|
|
17
17
|
Toast.error(formatError(err));
|
|
18
18
|
onError === null || onError === void 0 ? void 0 : onError(err);
|
|
@@ -36,16 +36,16 @@ function UserCreditCard({ baseUrl, accessKey, onSuccess = () => { }, onError = (
|
|
|
36
36
|
minWidth: 0,
|
|
37
37
|
}, avatarProps: {
|
|
38
38
|
size: 24,
|
|
39
|
-
} })] }), (userInfoData === null || userInfoData === void 0 ? void 0 : userInfoData.enableCredit) ? (_jsxs(_Fragment, { children: [_jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [_jsx(Typography, { variant: "body2", color: "text.secondary", children: t('creditBalance') }),
|
|
39
|
+
} })] }), (userInfoData === null || userInfoData === void 0 ? void 0 : userInfoData.enableCredit) ? (_jsxs(_Fragment, { children: [_jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [_jsx(Typography, { variant: "body2", color: "text.secondary", children: t('creditBalance') }), _jsx(Typography, { variant: "h6", fontWeight: "bold", children: formatNumber(((_a = userInfoData === null || userInfoData === void 0 ? void 0 : userInfoData.creditBalance) === null || _a === void 0 ? void 0 : _a.balance) || '0') })] }), ((_b = userInfoData.creditBalance) === null || _b === void 0 ? void 0 : _b.pendingCredit) && Number(userInfoData.creditBalance.pendingCredit) > 0 && (_jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", children: [_jsx(Typography, { variant: "body2", color: "text.secondary", children: t('pendingCredit') }), _jsx(Typography, { variant: "h6", fontWeight: "bold", sx: { color: 'error.main' }, children: formatNumber(userInfoData.creditBalance.pendingCredit) })] })), _jsxs(Stack, { direction: "row", spacing: 1.5, sx: { mt: 1 }, className: "user-credit-card-actions", children: [(userInfoData === null || userInfoData === void 0 ? void 0 : userInfoData.paymentLink) && (_jsx(Button, { variant: "outlined", className: "recharge-button", onClick: () => {
|
|
40
40
|
window.open((userInfoData === null || userInfoData === void 0 ? void 0 : userInfoData.paymentLink) || '', '_blank');
|
|
41
41
|
}, sx: {
|
|
42
42
|
flex: 1,
|
|
43
|
-
}, children: t('recharge') })), _jsx(Button, { variant: "text", onClick: () => {
|
|
43
|
+
}, ...chargeBtnProps, children: t('recharge') })), _jsx(Button, { variant: "text", className: "manage-button", onClick: () => {
|
|
44
44
|
window.open((userInfoData === null || userInfoData === void 0 ? void 0 : userInfoData.profileLink) || '', '_blank');
|
|
45
45
|
}, sx: {
|
|
46
46
|
borderColor: 'primary.main',
|
|
47
47
|
color: 'primary.main',
|
|
48
|
-
}, children: t('manage') })] })] })) : (_jsxs(Alert, { severity: "info", sx: {
|
|
48
|
+
}, ...manageBtnProps, children: t('manage') })] })] })) : (_jsxs(Alert, { severity: "info", sx: {
|
|
49
49
|
textAlign: 'left',
|
|
50
50
|
}, children: [t('creditNotEnabled'), _jsx(Typography, { sx: {
|
|
51
51
|
display: 'inline-block',
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { ButtonProps } from '@mui/material';
|
|
1
2
|
import { UserInfoResult } from '../api/types/user';
|
|
2
3
|
interface UserCreditCardProps {
|
|
3
4
|
baseUrl: string;
|
|
4
|
-
|
|
5
|
+
apiKey: string;
|
|
5
6
|
onSuccess?: (userInfo: UserInfoResult) => void;
|
|
6
7
|
onError?: (error: Error) => void;
|
|
7
8
|
mode?: 'default' | 'custom';
|
|
8
9
|
render?: (userInfo: UserInfoResult) => React.ReactNode | null;
|
|
10
|
+
chargeBtnProps?: ButtonProps;
|
|
11
|
+
manageBtnProps?: ButtonProps;
|
|
9
12
|
}
|
|
10
13
|
declare const _default: import("react").ComponentType<UserCreditCardProps>;
|
|
11
14
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/aigne-hub",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.21",
|
|
4
4
|
"description": "The react.js component library for AIGNE Hub",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -94,10 +94,10 @@
|
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
96
|
"@arcblock/did": "^1.21.0",
|
|
97
|
-
"@arcblock/ux": "^3.0.
|
|
97
|
+
"@arcblock/ux": "^3.0.36",
|
|
98
98
|
"@blocklet/error": "0.2.5",
|
|
99
99
|
"@blocklet/logger": "^1.16.46",
|
|
100
|
-
"@blocklet/payment-js": "^1.19.
|
|
100
|
+
"@blocklet/payment-js": "^1.19.9",
|
|
101
101
|
"@blocklet/sdk": "^1.16.46",
|
|
102
102
|
"@emotion/css": "^11.13.5",
|
|
103
103
|
"@emotion/react": "^11.14.0",
|