@blocklet/ui-react 2.9.13 → 2.9.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/build.config.ts +29 -0
- package/es/@types/index.d.ts +63 -0
- package/es/@types/index.js +0 -0
- package/es/@types/shims.d.ts +12 -0
- package/es/Dashboard/index.d.ts +41 -0
- package/es/Dashboard/index.js +63 -97
- package/es/Footer/brand.d.ts +22 -0
- package/es/Footer/brand.js +20 -37
- package/es/Footer/copyright.d.ts +18 -0
- package/es/Footer/copyright.js +14 -16
- package/es/Footer/index.d.ts +6 -0
- package/es/Footer/index.js +30 -56
- package/es/Footer/internal-footer.d.ts +29 -0
- package/es/Footer/internal-footer.js +67 -94
- package/es/Footer/layout/plain.d.ts +15 -0
- package/es/Footer/layout/plain.js +19 -37
- package/es/Footer/layout/row.d.ts +18 -0
- package/es/Footer/layout/row.js +9 -19
- package/es/Footer/layout/standard.d.ts +15 -0
- package/es/Footer/layout/standard.js +29 -57
- package/es/Footer/links.d.ts +22 -0
- package/es/Footer/links.js +72 -104
- package/es/Footer/social-media.d.ts +14 -0
- package/es/Footer/social-media.js +35 -35
- package/es/Header/index.d.ts +9 -0
- package/es/Header/index.js +55 -100
- package/es/Icon/index.d.ts +23 -0
- package/es/Icon/index.js +23 -58
- package/es/UserCenter/assets/banner.png +0 -0
- package/es/UserCenter/components/notification.d.ts +5 -0
- package/es/UserCenter/components/notification.js +276 -0
- package/es/UserCenter/components/passport.d.ts +6 -0
- package/es/UserCenter/components/passport.js +69 -0
- package/es/UserCenter/components/privacy.d.ts +11 -0
- package/es/UserCenter/components/privacy.js +99 -0
- package/es/UserCenter/components/settings.d.ts +10 -0
- package/es/UserCenter/components/settings.js +68 -0
- package/es/UserCenter/components/user-basic-info.d.ts +8 -0
- package/es/UserCenter/components/user-basic-info.js +66 -0
- package/es/UserCenter/components/user-center.d.ts +9 -0
- package/es/UserCenter/components/user-center.js +397 -0
- package/es/UserCenter/components/user-info-item.d.ts +10 -0
- package/es/UserCenter/components/user-info-item.js +54 -0
- package/es/UserCenter/components/user-info.d.ts +6 -0
- package/es/UserCenter/components/user-info.js +68 -0
- package/es/UserCenter/components/webhook-item.d.ts +3 -0
- package/es/UserCenter/components/webhook-item.js +243 -0
- package/es/UserCenter/index.d.ts +1 -0
- package/es/UserCenter/index.js +1 -0
- package/es/UserCenter/libs/client.d.ts +2 -0
- package/es/UserCenter/libs/client.js +2 -0
- package/es/UserCenter/libs/locales.d.ts +72 -0
- package/es/UserCenter/libs/locales.js +72 -0
- package/es/UserCenter/libs/utils.d.ts +4 -0
- package/es/UserCenter/libs/utils.js +14 -0
- package/es/blocklets.d.ts +16 -0
- package/es/blocklets.js +56 -45
- package/es/common/header-addons.d.ts +22 -0
- package/es/common/header-addons.js +41 -59
- package/es/common/link-blocker.d.ts +7 -0
- package/es/common/link-blocker.js +10 -17
- package/es/common/overridable-theme-provider.d.ts +18 -0
- package/es/common/overridable-theme-provider.js +6 -16
- package/es/common/wallet-hidden-topbar.d.ts +1 -0
- package/es/common/wallet-hidden-topbar.js +12 -10
- package/es/index.d.ts +5 -0
- package/es/index.js +5 -0
- package/es/types.d.ts +2 -0
- package/es/types.js +17 -11
- package/es/utils.d.ts +8 -0
- package/es/utils.js +21 -26
- package/lib/@types/index.d.ts +63 -0
- package/lib/@types/index.js +1 -0
- package/lib/@types/shims.d.ts +12 -0
- package/lib/Dashboard/index.d.ts +41 -0
- package/lib/Dashboard/index.js +44 -71
- package/lib/Footer/brand.d.ts +22 -0
- package/lib/Footer/brand.js +65 -30
- package/lib/Footer/copyright.d.ts +18 -0
- package/lib/Footer/copyright.js +18 -23
- package/lib/Footer/index.d.ts +6 -0
- package/lib/Footer/index.js +33 -42
- package/lib/Footer/internal-footer.d.ts +29 -0
- package/lib/Footer/internal-footer.js +43 -59
- package/lib/Footer/layout/plain.d.ts +15 -0
- package/lib/Footer/layout/plain.js +25 -30
- package/lib/Footer/layout/row.d.ts +18 -0
- package/lib/Footer/layout/row.js +34 -23
- package/lib/Footer/layout/standard.d.ts +15 -0
- package/lib/Footer/layout/standard.js +35 -41
- package/lib/Footer/links.d.ts +22 -0
- package/lib/Footer/links.js +163 -60
- package/lib/Footer/social-media.d.ts +14 -0
- package/lib/Footer/social-media.js +31 -25
- package/lib/Header/index.d.ts +9 -0
- package/lib/Header/index.js +83 -76
- package/lib/Icon/index.d.ts +23 -0
- package/lib/Icon/index.js +37 -51
- package/lib/UserCenter/assets/banner.png +0 -0
- package/lib/UserCenter/components/notification.d.ts +5 -0
- package/lib/UserCenter/components/notification.js +261 -0
- package/lib/UserCenter/components/passport.d.ts +6 -0
- package/lib/UserCenter/components/passport.js +86 -0
- package/lib/UserCenter/components/privacy.d.ts +11 -0
- package/lib/UserCenter/components/privacy.js +101 -0
- package/lib/UserCenter/components/settings.d.ts +10 -0
- package/lib/UserCenter/components/settings.js +81 -0
- package/lib/UserCenter/components/user-basic-info.d.ts +8 -0
- package/lib/UserCenter/components/user-basic-info.js +67 -0
- package/lib/UserCenter/components/user-center.d.ts +9 -0
- package/lib/UserCenter/components/user-center.js +376 -0
- package/lib/UserCenter/components/user-info-item.d.ts +10 -0
- package/lib/UserCenter/components/user-info-item.js +46 -0
- package/lib/UserCenter/components/user-info.d.ts +6 -0
- package/lib/UserCenter/components/user-info.js +94 -0
- package/lib/UserCenter/components/webhook-item.d.ts +3 -0
- package/lib/UserCenter/components/webhook-item.js +236 -0
- package/lib/UserCenter/index.d.ts +1 -0
- package/lib/UserCenter/index.js +13 -0
- package/lib/UserCenter/libs/client.d.ts +2 -0
- package/lib/UserCenter/libs/client.js +8 -0
- package/lib/UserCenter/libs/locales.d.ts +72 -0
- package/lib/UserCenter/libs/locales.js +78 -0
- package/lib/UserCenter/libs/utils.d.ts +4 -0
- package/lib/UserCenter/libs/utils.js +25 -0
- package/lib/blocklets.d.ts +16 -0
- package/lib/blocklets.js +28 -36
- package/lib/common/header-addons.d.ts +22 -0
- package/lib/common/header-addons.js +24 -36
- package/lib/common/link-blocker.d.ts +7 -0
- package/lib/common/link-blocker.js +10 -18
- package/lib/common/overridable-theme-provider.d.ts +18 -0
- package/lib/common/overridable-theme-provider.js +9 -14
- package/lib/common/wallet-hidden-topbar.d.ts +1 -0
- package/lib/common/wallet-hidden-topbar.js +1 -3
- package/lib/index.d.ts +5 -0
- package/lib/index.js +52 -0
- package/lib/types.d.ts +2 -0
- package/lib/types.js +3 -5
- package/lib/utils.d.ts +8 -0
- package/lib/utils.js +16 -23
- package/package.json +17 -11
- package/src/@types/index.ts +70 -0
- package/src/@types/shims.d.ts +12 -0
- package/src/UserCenter/assets/banner.png +0 -0
- package/src/UserCenter/components/notification.tsx +275 -0
- package/src/UserCenter/components/passport.tsx +83 -0
- package/src/UserCenter/components/privacy.tsx +107 -0
- package/src/UserCenter/components/settings.tsx +78 -0
- package/src/UserCenter/components/user-basic-info.tsx +70 -0
- package/src/UserCenter/components/user-center.tsx +410 -0
- package/src/UserCenter/components/user-info-item.tsx +50 -0
- package/src/UserCenter/components/user-info.tsx +85 -0
- package/src/UserCenter/components/webhook-item.tsx +243 -0
- package/src/UserCenter/index.tsx +1 -0
- package/src/UserCenter/libs/client.ts +3 -0
- package/src/UserCenter/libs/locales.ts +72 -0
- package/src/UserCenter/libs/utils.ts +21 -0
- package/src/blocklets.js +2 -0
- package/src/index.ts +9 -0
- /package/src/common/{link-blocker.js → link-blocker.jsx} +0 -0
package/es/Icon/index.js
CHANGED
|
@@ -1,78 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
export default function Icon({
|
|
11
|
-
icon,
|
|
12
|
-
size,
|
|
13
|
-
sx,
|
|
14
|
-
...rest
|
|
15
|
-
}) {
|
|
16
|
-
const _sx = [...(Array.isArray(sx) ? sx : [sx])];
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "iconify-icon";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import Avatar from "@mui/material/Avatar";
|
|
5
|
+
import { isUrl, isIconifyString } from "../utils.js";
|
|
6
|
+
export default function Icon({ icon, size, sx, ...rest }) {
|
|
7
|
+
const _sx = [...Array.isArray(sx) ? sx : [sx]];
|
|
17
8
|
if (size) {
|
|
18
|
-
_sx.push({
|
|
19
|
-
width: size,
|
|
20
|
-
height: size
|
|
21
|
-
});
|
|
9
|
+
_sx.push({ width: size, height: size });
|
|
22
10
|
}
|
|
23
|
-
// 禁用默认的 circular variant 样式
|
|
24
11
|
if (!rest.variant) {
|
|
25
12
|
_sx.push({
|
|
26
|
-
|
|
27
|
-
color:
|
|
28
|
-
fontWeight:
|
|
29
|
-
backgroundColor:
|
|
13
|
+
"&.MuiAvatar-root": {
|
|
14
|
+
color: "inherit",
|
|
15
|
+
fontWeight: "bold",
|
|
16
|
+
backgroundColor: "transparent",
|
|
30
17
|
borderRadius: 0
|
|
31
18
|
},
|
|
32
19
|
// 无 icon 背景时, svg icon 尺寸与窗口尺寸一致
|
|
33
|
-
|
|
34
|
-
width:
|
|
35
|
-
height:
|
|
20
|
+
"&.MuiAvatar-root svg": {
|
|
21
|
+
width: "100%",
|
|
22
|
+
height: "100%"
|
|
36
23
|
}
|
|
37
24
|
});
|
|
38
25
|
}
|
|
39
26
|
if (isUrl(icon)) {
|
|
40
|
-
return
|
|
41
|
-
as: "span",
|
|
42
|
-
...rest,
|
|
43
|
-
src: icon,
|
|
44
|
-
sx: _sx
|
|
45
|
-
});
|
|
27
|
+
return /* @__PURE__ */ jsx(Avatar, { as: "span", ...rest, src: icon, sx: _sx });
|
|
46
28
|
}
|
|
47
29
|
if (isIconifyString(icon)) {
|
|
48
|
-
// y = 0.6 * x + 4
|
|
49
30
|
const height = size ? 0.6 * size + 4 : 0;
|
|
50
|
-
return
|
|
51
|
-
as: "span",
|
|
52
|
-
...rest,
|
|
53
|
-
sx: _sx,
|
|
54
|
-
children: /*#__PURE__*/_jsx("iconify-icon", {
|
|
55
|
-
icon: icon,
|
|
56
|
-
height: height || undefined
|
|
57
|
-
})
|
|
58
|
-
});
|
|
31
|
+
return /* @__PURE__ */ jsx(Avatar, { as: "span", ...rest, sx: _sx, children: /* @__PURE__ */ jsx("iconify-icon", { icon, height: height || void 0 }) });
|
|
59
32
|
}
|
|
60
|
-
|
|
61
|
-
if (icon && typeof icon === 'string') {
|
|
33
|
+
if (icon && typeof icon === "string") {
|
|
62
34
|
_sx.push({
|
|
63
|
-
|
|
64
|
-
display:
|
|
65
|
-
...
|
|
66
|
-
fontSize: size - 2
|
|
67
|
-
})
|
|
35
|
+
"&.MuiAvatar-root": {
|
|
36
|
+
display: "inline-flex",
|
|
37
|
+
...size && { fontSize: size - 2 }
|
|
68
38
|
}
|
|
69
39
|
});
|
|
70
|
-
return
|
|
71
|
-
as: "span",
|
|
72
|
-
...rest,
|
|
73
|
-
sx: _sx,
|
|
74
|
-
children: Array.from(icon)[0]
|
|
75
|
-
});
|
|
40
|
+
return /* @__PURE__ */ jsx(Avatar, { as: "span", ...rest, sx: _sx, children: Array.from(icon)[0] });
|
|
76
41
|
}
|
|
77
42
|
return null;
|
|
78
43
|
}
|
|
@@ -87,4 +52,4 @@ Icon.propTypes = {
|
|
|
87
52
|
Icon.defaultProps = {
|
|
88
53
|
size: null,
|
|
89
54
|
sx: null
|
|
90
|
-
};
|
|
55
|
+
};
|
|
Binary file
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Alert, Box, CircularProgress, Divider, Stack, Typography } from "@mui/material";
|
|
3
|
+
import { useCreation, useMemoizedFn, useReactive, useRequest } from "ahooks";
|
|
4
|
+
import { Icon } from "@iconify/react";
|
|
5
|
+
import AddRoundedIcon from "@iconify-icons/material-symbols/add-rounded";
|
|
6
|
+
import Switch from "@arcblock/ux/lib/Switch";
|
|
7
|
+
import Button from "@arcblock/ux/lib/Button";
|
|
8
|
+
import { temp as colors } from "@arcblock/ux/lib/Colors";
|
|
9
|
+
import Toast from "@arcblock/ux/lib/Toast";
|
|
10
|
+
import { getWalletDid } from "@arcblock/ux/lib/SessionUser/libs/utils";
|
|
11
|
+
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
12
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
13
|
+
import { translations } from "../libs/locales.js";
|
|
14
|
+
import WebhookItem from "./webhook-item.js";
|
|
15
|
+
import { formatAxiosError } from "../libs/utils.js";
|
|
16
|
+
import { client } from "../libs/client.js";
|
|
17
|
+
export default function Notification({ user }) {
|
|
18
|
+
const { locale } = useLocaleContext();
|
|
19
|
+
const t = useMemoizedFn((key, data = {}) => {
|
|
20
|
+
return translate(translations, key, locale, "en", data);
|
|
21
|
+
});
|
|
22
|
+
const currentState = useReactive({
|
|
23
|
+
showAdd: false
|
|
24
|
+
});
|
|
25
|
+
const notificationConfigState = useRequest(
|
|
26
|
+
async () => {
|
|
27
|
+
const data = await client.user.getUserNotificationConfig();
|
|
28
|
+
return data;
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
refreshDeps: [user],
|
|
32
|
+
loadingDelay: 300
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
const notifications = useCreation(() => {
|
|
36
|
+
return {
|
|
37
|
+
wallet: true,
|
|
38
|
+
email: true,
|
|
39
|
+
phone: false,
|
|
40
|
+
...notificationConfigState?.data?.notifications || {}
|
|
41
|
+
};
|
|
42
|
+
}, [notificationConfigState?.data?.notifications]);
|
|
43
|
+
const webhooks = useCreation(() => {
|
|
44
|
+
return notificationConfigState?.data?.webhooks || [];
|
|
45
|
+
}, [notificationConfigState?.data?.webhooks]);
|
|
46
|
+
const onSaveChanges = useMemoizedFn(async (values) => {
|
|
47
|
+
try {
|
|
48
|
+
await client.user.saveUserNotificationConfig(values);
|
|
49
|
+
Toast.success(t("saveSuccess"));
|
|
50
|
+
notificationConfigState.run();
|
|
51
|
+
} catch (err) {
|
|
52
|
+
Toast.error(formatAxiosError(err));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const handleChangeSwitch = useMemoizedFn(async (channel, value) => {
|
|
56
|
+
await onSaveChanges({
|
|
57
|
+
notifications: {
|
|
58
|
+
[channel]: value
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
const handleTestWebhook = async (data) => {
|
|
63
|
+
try {
|
|
64
|
+
await client.user.testNotificationWebhook(data);
|
|
65
|
+
Toast.success(t("webhookTested"));
|
|
66
|
+
} catch (err) {
|
|
67
|
+
Toast.error(formatAxiosError(err));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const handleDeleteWebhook = useMemoizedFn(async (index) => {
|
|
71
|
+
await onSaveChanges({
|
|
72
|
+
webhooks: webhooks.filter((_, i) => i !== index)
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
const handleEditWebhook = useMemoizedFn(async (index, webhook) => {
|
|
76
|
+
await onSaveChanges({
|
|
77
|
+
webhooks: webhooks.map((item, i) => i === index ? webhook : item)
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
const handleAddWebhook = useMemoizedFn(async (webhook) => {
|
|
81
|
+
await onSaveChanges({
|
|
82
|
+
webhooks: [...webhooks, webhook]
|
|
83
|
+
});
|
|
84
|
+
currentState.showAdd = false;
|
|
85
|
+
});
|
|
86
|
+
if (notificationConfigState.error) {
|
|
87
|
+
return /* @__PURE__ */ jsx(Alert, { severity: "error", children: notificationConfigState.error.message });
|
|
88
|
+
}
|
|
89
|
+
if (notificationConfigState.loading || !notificationConfigState.data) {
|
|
90
|
+
return /* @__PURE__ */ jsx(
|
|
91
|
+
Box,
|
|
92
|
+
{
|
|
93
|
+
sx: {
|
|
94
|
+
display: "flex",
|
|
95
|
+
justifyContent: "center",
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
height: "100px"
|
|
98
|
+
},
|
|
99
|
+
children: /* @__PURE__ */ jsx(CircularProgress, {})
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", gap: 2 }, children: [
|
|
104
|
+
/* @__PURE__ */ jsxs(
|
|
105
|
+
Box,
|
|
106
|
+
{
|
|
107
|
+
sx: {
|
|
108
|
+
display: "flex",
|
|
109
|
+
flexDirection: "column",
|
|
110
|
+
gap: 1,
|
|
111
|
+
alignItems: "start",
|
|
112
|
+
".MuiFormControlLabel-root": {
|
|
113
|
+
gap: 1,
|
|
114
|
+
m: 0,
|
|
115
|
+
flexDirection: {
|
|
116
|
+
xs: "row-reverse",
|
|
117
|
+
md: "row"
|
|
118
|
+
},
|
|
119
|
+
width: {
|
|
120
|
+
xs: "100%",
|
|
121
|
+
md: "unset"
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
".MuiSwitch-track": {
|
|
125
|
+
borderRadius: "100vw"
|
|
126
|
+
},
|
|
127
|
+
".MuiSwitch-thumb": {
|
|
128
|
+
borderRadius: "100%"
|
|
129
|
+
},
|
|
130
|
+
".MuiSwitch-root.MuiSwitch-sizeSmall": {
|
|
131
|
+
height: "20px",
|
|
132
|
+
width: "36px",
|
|
133
|
+
".MuiSwitch-thumb": {
|
|
134
|
+
width: "16px",
|
|
135
|
+
height: "16px"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
children: [
|
|
140
|
+
/* @__PURE__ */ jsx(
|
|
141
|
+
Switch,
|
|
142
|
+
{
|
|
143
|
+
checked: notifications.wallet,
|
|
144
|
+
labelProps: {
|
|
145
|
+
label: /* @__PURE__ */ jsxs(
|
|
146
|
+
Typography,
|
|
147
|
+
{
|
|
148
|
+
color: "text.primary",
|
|
149
|
+
sx: {
|
|
150
|
+
fontSize: 14,
|
|
151
|
+
display: "flex",
|
|
152
|
+
flexFlow: "wrap",
|
|
153
|
+
columnGap: 1,
|
|
154
|
+
flex: 1
|
|
155
|
+
},
|
|
156
|
+
children: [
|
|
157
|
+
t("walletNotification"),
|
|
158
|
+
getWalletDid(user) && /* @__PURE__ */ jsx(Typography, { component: "span", color: "text.secondary", fontSize: 13, children: getWalletDid(user) })
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
)
|
|
162
|
+
},
|
|
163
|
+
size: "small",
|
|
164
|
+
onChange: (event) => handleChangeSwitch("wallet", event.target.checked)
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
/* @__PURE__ */ jsx(
|
|
168
|
+
Switch,
|
|
169
|
+
{
|
|
170
|
+
checked: notifications.email,
|
|
171
|
+
labelProps: {
|
|
172
|
+
label: /* @__PURE__ */ jsxs(
|
|
173
|
+
Typography,
|
|
174
|
+
{
|
|
175
|
+
color: "text.primary",
|
|
176
|
+
sx: {
|
|
177
|
+
fontSize: 14,
|
|
178
|
+
display: "flex",
|
|
179
|
+
flexFlow: "wrap",
|
|
180
|
+
columnGap: 1,
|
|
181
|
+
flex: 1
|
|
182
|
+
},
|
|
183
|
+
children: [
|
|
184
|
+
t("emailNotification"),
|
|
185
|
+
user?.email && /* @__PURE__ */ jsx(Typography, { component: "span", color: "text.secondary", fontSize: 13, children: user?.email })
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
},
|
|
190
|
+
size: "small",
|
|
191
|
+
onChange: (event) => handleChangeSwitch("email", event.target.checked)
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
/* @__PURE__ */ jsx(
|
|
195
|
+
Switch,
|
|
196
|
+
{
|
|
197
|
+
disabled: true,
|
|
198
|
+
checked: notifications.phone,
|
|
199
|
+
labelProps: {
|
|
200
|
+
label: /* @__PURE__ */ jsxs(
|
|
201
|
+
Typography,
|
|
202
|
+
{
|
|
203
|
+
color: "text.primary",
|
|
204
|
+
sx: {
|
|
205
|
+
fontSize: 14,
|
|
206
|
+
display: "flex",
|
|
207
|
+
flexFlow: "wrap",
|
|
208
|
+
columnGap: 1,
|
|
209
|
+
flex: 1
|
|
210
|
+
},
|
|
211
|
+
children: [
|
|
212
|
+
t("phoneNotification"),
|
|
213
|
+
user?.phone && /* @__PURE__ */ jsx(Typography, { component: "span", color: "text.secondary", fontSize: 13, children: user?.phone })
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
)
|
|
217
|
+
},
|
|
218
|
+
size: "small",
|
|
219
|
+
onChange: (event) => handleChangeSwitch("phone", event.target.checked)
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
),
|
|
225
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
226
|
+
/* @__PURE__ */ jsxs(Stack, { spacing: 1.5, useFlexGap: true, direction: "column", alignItems: "start", children: [
|
|
227
|
+
webhooks.map((item, index) => /* @__PURE__ */ jsx(
|
|
228
|
+
WebhookItem,
|
|
229
|
+
{
|
|
230
|
+
onTest: handleTestWebhook,
|
|
231
|
+
onDelete: () => handleDeleteWebhook(index),
|
|
232
|
+
onSave: (...args) => handleEditWebhook(index, ...args),
|
|
233
|
+
type: item.type,
|
|
234
|
+
url: item.url,
|
|
235
|
+
edit: false
|
|
236
|
+
},
|
|
237
|
+
`${index}_${item.url}`
|
|
238
|
+
)),
|
|
239
|
+
currentState.showAdd && /* @__PURE__ */ jsx(
|
|
240
|
+
WebhookItem,
|
|
241
|
+
{
|
|
242
|
+
onTest: handleTestWebhook,
|
|
243
|
+
onCancel: () => {
|
|
244
|
+
currentState.showAdd = false;
|
|
245
|
+
},
|
|
246
|
+
onSave: (...args) => handleAddWebhook(...args),
|
|
247
|
+
edit: true
|
|
248
|
+
},
|
|
249
|
+
"add"
|
|
250
|
+
),
|
|
251
|
+
/* @__PURE__ */ jsx(
|
|
252
|
+
Button,
|
|
253
|
+
{
|
|
254
|
+
variant: "outlined",
|
|
255
|
+
size: "small",
|
|
256
|
+
sx: {
|
|
257
|
+
color: colors.foregroundsFgBase,
|
|
258
|
+
borderColor: colors.strokeBorderBase,
|
|
259
|
+
backgroundColor: colors.buttonsButtonNeutral,
|
|
260
|
+
"&:hover": {
|
|
261
|
+
borderColor: colors.strokeBorderBase,
|
|
262
|
+
backgroundColor: colors.buttonsButtonNeutralHover
|
|
263
|
+
},
|
|
264
|
+
py: 0.5,
|
|
265
|
+
borderRadius: 2
|
|
266
|
+
},
|
|
267
|
+
startIcon: /* @__PURE__ */ jsx(Icon, { icon: AddRoundedIcon }),
|
|
268
|
+
onClick: () => {
|
|
269
|
+
currentState.showAdd = true;
|
|
270
|
+
},
|
|
271
|
+
children: t("addWebhook")
|
|
272
|
+
}
|
|
273
|
+
)
|
|
274
|
+
] })
|
|
275
|
+
] });
|
|
276
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Stack } from "@mui/material";
|
|
3
|
+
import Empty from "@arcblock/ux/lib/Empty";
|
|
4
|
+
import { useTheme } from "@arcblock/ux/lib/Theme";
|
|
5
|
+
import { temp as colors } from "@arcblock/ux/lib/Colors";
|
|
6
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
7
|
+
import PassportItem from "@arcblock/ux/lib/Passport";
|
|
8
|
+
import { PASSPORT_STATUS } from "@abtnode/constant";
|
|
9
|
+
import { useCreation } from "ahooks";
|
|
10
|
+
import uniqBy from "lodash/uniqBy";
|
|
11
|
+
import { createPassportSvg } from "../libs/utils.js";
|
|
12
|
+
export default function Passport({ user, ...rest }) {
|
|
13
|
+
const { t } = useLocaleContext();
|
|
14
|
+
const theme = useTheme();
|
|
15
|
+
const passports = useCreation(() => {
|
|
16
|
+
const passportList = (user?.passports || []).map((x) => ({
|
|
17
|
+
...x,
|
|
18
|
+
revoked: x.status === PASSPORT_STATUS.REVOKED
|
|
19
|
+
}));
|
|
20
|
+
passportList.sort((a, b) => {
|
|
21
|
+
if (a.revoked === b.revoked) {
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
if (a.revoked) {
|
|
25
|
+
return 1;
|
|
26
|
+
} else {
|
|
27
|
+
return -1;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return uniqBy(passportList, "role");
|
|
31
|
+
}, [user?.passports]);
|
|
32
|
+
const currentRole = useCreation(() => passports?.find((item) => item.name === user.role), [passports, user?.role]);
|
|
33
|
+
const activeColor = useCreation(() => {
|
|
34
|
+
return theme?.palette?.primary?.main || colors.textBase;
|
|
35
|
+
}, [theme?.palette?.primary?.main]);
|
|
36
|
+
if (passports.length === 0) {
|
|
37
|
+
return /* @__PURE__ */ jsx(Empty, { children: t("noPassport") });
|
|
38
|
+
}
|
|
39
|
+
return /* @__PURE__ */ jsx(Stack, { direction: "row", spacing: 3, flexWrap: "wrap", useFlexGap: true, ...rest, children: passports.map((x) => /* @__PURE__ */ jsx(
|
|
40
|
+
PassportItem,
|
|
41
|
+
{
|
|
42
|
+
passport: x,
|
|
43
|
+
user,
|
|
44
|
+
width: 200,
|
|
45
|
+
color: window.blocklet.passportColor,
|
|
46
|
+
createPassportSvg,
|
|
47
|
+
title: currentRole.role === x.role ? t("currentPassport") : "",
|
|
48
|
+
sx: {
|
|
49
|
+
flexDirection: "column",
|
|
50
|
+
alignItems: "center",
|
|
51
|
+
gap: 1,
|
|
52
|
+
".passport-item__display": {
|
|
53
|
+
width: 166,
|
|
54
|
+
height: 166,
|
|
55
|
+
borderRadius: 2,
|
|
56
|
+
px: 2,
|
|
57
|
+
display: "flex",
|
|
58
|
+
justifyContent: "center",
|
|
59
|
+
backgroundColor: "white",
|
|
60
|
+
boxShadow: currentRole.role === x.role ? `0px 2px 4px 0px ${activeColor}, 0px 1px 2px -1px ${activeColor}, 0px 0px 0px 1px ${activeColor} !important` : "0px 2px 4px 0px rgba(2, 7, 19, 0.04), 0px 1px 2px -1px rgba(2, 7, 19, 0.08), 0px 0px 0px 1px rgba(2, 7, 19, 0.08) !important"
|
|
61
|
+
},
|
|
62
|
+
".passport-item__body": {
|
|
63
|
+
marginLeft: "0 !important"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
x.id
|
|
68
|
+
)) });
|
|
69
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type PrivacyConfig = {
|
|
3
|
+
key: string;
|
|
4
|
+
name: string;
|
|
5
|
+
value: boolean;
|
|
6
|
+
};
|
|
7
|
+
export default function Privacy({ configList, onSave }: {
|
|
8
|
+
configList: PrivacyConfig[];
|
|
9
|
+
onSave: () => void;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Typography } from "@mui/material";
|
|
3
|
+
import Switch from "@arcblock/ux/lib/Switch";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { useMemoizedFn } from "ahooks";
|
|
6
|
+
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
7
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
8
|
+
import Toast from "@arcblock/ux/lib/Toast";
|
|
9
|
+
import { translations } from "../libs/locales.js";
|
|
10
|
+
import { client } from "../libs/client.js";
|
|
11
|
+
import { formatAxiosError } from "../libs/utils.js";
|
|
12
|
+
export default function Privacy({ configList, onSave }) {
|
|
13
|
+
const [dataList, setDataList] = useState(configList);
|
|
14
|
+
const { locale } = useLocaleContext();
|
|
15
|
+
const t = useMemoizedFn((key, data = {}) => {
|
|
16
|
+
return translate(translations, key, locale, "en", data);
|
|
17
|
+
});
|
|
18
|
+
const handleChangeSwitch = useMemoizedFn(async (type, value) => {
|
|
19
|
+
try {
|
|
20
|
+
const result = await client.user.saveUserPrivacyConfig({
|
|
21
|
+
[type]: !value
|
|
22
|
+
});
|
|
23
|
+
setDataList(
|
|
24
|
+
dataList.map((item) => {
|
|
25
|
+
return {
|
|
26
|
+
...item,
|
|
27
|
+
value: result?.[item.key] ?? item.value
|
|
28
|
+
};
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
Toast.success(t("saveSuccess"));
|
|
32
|
+
onSave();
|
|
33
|
+
} catch (err) {
|
|
34
|
+
Toast.error(formatAxiosError(err));
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return /* @__PURE__ */ jsx(
|
|
38
|
+
Box,
|
|
39
|
+
{
|
|
40
|
+
sx: {
|
|
41
|
+
display: "flex",
|
|
42
|
+
flexDirection: "column",
|
|
43
|
+
gap: 1,
|
|
44
|
+
alignItems: "start",
|
|
45
|
+
".MuiFormControlLabel-root": {
|
|
46
|
+
gap: 1,
|
|
47
|
+
m: 0,
|
|
48
|
+
flexDirection: {
|
|
49
|
+
xs: "row-reverse",
|
|
50
|
+
md: "row"
|
|
51
|
+
},
|
|
52
|
+
width: {
|
|
53
|
+
xs: "100%",
|
|
54
|
+
md: "unset"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
".MuiSwitch-track": {
|
|
58
|
+
borderRadius: "100vw"
|
|
59
|
+
},
|
|
60
|
+
".MuiSwitch-thumb": {
|
|
61
|
+
borderRadius: "100%"
|
|
62
|
+
},
|
|
63
|
+
".MuiSwitch-root.MuiSwitch-sizeSmall": {
|
|
64
|
+
height: "20px",
|
|
65
|
+
width: "36px",
|
|
66
|
+
".MuiSwitch-thumb": {
|
|
67
|
+
width: "16px",
|
|
68
|
+
height: "16px"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
children: dataList.map((item) => /* @__PURE__ */ jsx(
|
|
73
|
+
Switch,
|
|
74
|
+
{
|
|
75
|
+
checked: !item.value,
|
|
76
|
+
labelProps: {
|
|
77
|
+
label: /* @__PURE__ */ jsx(
|
|
78
|
+
Typography,
|
|
79
|
+
{
|
|
80
|
+
color: "text.primary",
|
|
81
|
+
sx: {
|
|
82
|
+
fontSize: 14,
|
|
83
|
+
display: "flex",
|
|
84
|
+
flexFlow: "wrap",
|
|
85
|
+
columnGap: 1,
|
|
86
|
+
flex: 1
|
|
87
|
+
},
|
|
88
|
+
children: t("toPublic", { name: item.name })
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
},
|
|
92
|
+
size: "small",
|
|
93
|
+
onChange: (event) => handleChangeSwitch(item.key, event.target.checked)
|
|
94
|
+
},
|
|
95
|
+
item.key
|
|
96
|
+
))
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { BoxProps } from '@mui/material';
|
|
3
|
+
import { User, UserCenterTab } from '../../@types';
|
|
4
|
+
export default function Settings({ user, settings, onSave, ...rest }: {
|
|
5
|
+
user: User;
|
|
6
|
+
onSave: () => void;
|
|
7
|
+
settings: {
|
|
8
|
+
userCenterTabs: UserCenterTab[];
|
|
9
|
+
};
|
|
10
|
+
} & BoxProps): import("react").JSX.Element | undefined;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Tabs from "@arcblock/ux/lib/Tabs";
|
|
3
|
+
import { Box } from "@mui/material";
|
|
4
|
+
import { useCreation, useMemoizedFn, useReactive } from "ahooks";
|
|
5
|
+
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
6
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
7
|
+
import { translations } from "../libs/locales.js";
|
|
8
|
+
import Notification from "./notification.js";
|
|
9
|
+
import Privacy from "./privacy.js";
|
|
10
|
+
export default function Settings({
|
|
11
|
+
user,
|
|
12
|
+
settings,
|
|
13
|
+
onSave,
|
|
14
|
+
...rest
|
|
15
|
+
}) {
|
|
16
|
+
const { locale } = useLocaleContext();
|
|
17
|
+
const t = useMemoizedFn((key, data = {}) => {
|
|
18
|
+
return translate(translations, key, locale, "en", data);
|
|
19
|
+
});
|
|
20
|
+
const privacyConfigList = useCreation(() => {
|
|
21
|
+
const userCenterTabs = settings?.userCenterTabs || [];
|
|
22
|
+
return userCenterTabs.map((item) => {
|
|
23
|
+
return {
|
|
24
|
+
key: item.value,
|
|
25
|
+
name: item.label,
|
|
26
|
+
value: item.protected
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}, [settings?.userCenterTabs]);
|
|
30
|
+
const tabs = useCreation(() => {
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
label: t("notificationManagement"),
|
|
34
|
+
value: "notification",
|
|
35
|
+
content: /* @__PURE__ */ jsx(Notification, { user })
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: t("privacyManagement"),
|
|
39
|
+
value: "privacy",
|
|
40
|
+
content: /* @__PURE__ */ jsx(Privacy, { configList: privacyConfigList, onSave })
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
}, [user, privacyConfigList]);
|
|
44
|
+
const currentState = useReactive({
|
|
45
|
+
tab: tabs[0].value
|
|
46
|
+
});
|
|
47
|
+
const currentTab = useCreation(() => {
|
|
48
|
+
return tabs.find((x) => x.value === currentState.tab);
|
|
49
|
+
}, [currentState.tab]);
|
|
50
|
+
const handleChangeTab = useMemoizedFn((value) => {
|
|
51
|
+
currentState.tab = value;
|
|
52
|
+
});
|
|
53
|
+
return currentTab && /* @__PURE__ */ jsxs(
|
|
54
|
+
Box,
|
|
55
|
+
{
|
|
56
|
+
...rest,
|
|
57
|
+
sx: {
|
|
58
|
+
...rest?.sx,
|
|
59
|
+
width: 520,
|
|
60
|
+
maxWidth: "100%"
|
|
61
|
+
},
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ jsx(Tabs, { variant: "card", tabs, current: currentTab.value, onChange: handleChangeTab }),
|
|
64
|
+
/* @__PURE__ */ jsx(Box, { mt: 2.5, children: currentTab.content })
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { BoxProps } from '@mui/material';
|
|
3
|
+
import type { User } from '../../@types';
|
|
4
|
+
export default function UserBasicInfo({ user, isMyself, switchPassport, ...rest }: {
|
|
5
|
+
user: User;
|
|
6
|
+
isMyself: boolean;
|
|
7
|
+
switchPassport: () => void;
|
|
8
|
+
} & BoxProps): import("react").JSX.Element;
|