@blocklet/ui-react 3.1.55 → 3.1.57
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/lib/UserCenter/components/user-center.js +160 -155
- package/lib/UserCenter/components/user-info/address.js +21 -16
- package/lib/UserCenter/libs/locales.d.ts +4 -0
- package/lib/UserCenter/libs/locales.js +6 -2
- package/package.json +6 -6
- package/src/UserCenter/components/user-center.tsx +16 -0
- package/src/UserCenter/components/user-info/address.tsx +5 -0
- package/src/UserCenter/libs/locales.ts +4 -0
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { jsx as r, jsxs as m } from "react/jsx-runtime";
|
|
2
|
-
import { use as
|
|
3
|
-
import { Box as
|
|
4
|
-
import { useMemoizedFn as C, useCreation as
|
|
2
|
+
import { use as ke, useMemo as Ce, isValidElement as ee, cloneElement as re, Children as Pe } from "react";
|
|
3
|
+
import { Box as l, Typography as T, CircularProgress as Se, Divider as Me } from "@mui/material";
|
|
4
|
+
import { useMemoizedFn as C, useCreation as u, useRequest as te } from "ahooks";
|
|
5
5
|
import De from "p-wait-for";
|
|
6
|
-
import
|
|
7
|
-
import { SessionContext as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
6
|
+
import ie from "react-helmet";
|
|
7
|
+
import { SessionContext as Fe } from "@arcblock/did-connect-react/lib/Session";
|
|
8
|
+
import Te from "@arcblock/ux/lib/Tabs";
|
|
9
|
+
import z from "@arcblock/ux/lib/Empty";
|
|
10
10
|
import ze from "@arcblock/ux/lib/Button";
|
|
11
11
|
import We from "@arcblock/ux/lib/Result";
|
|
12
12
|
import { useConfirm as Ae } from "@arcblock/ux/lib/Dialog";
|
|
13
13
|
import { translate as Le } from "@arcblock/ux/lib/Locale/util";
|
|
14
14
|
import { useLocaleContext as Ue } from "@arcblock/ux/lib/Locale/context";
|
|
15
15
|
import { ErrorFallback as Be } from "@arcblock/ux/lib/ErrorBoundary";
|
|
16
|
-
import { styled as
|
|
16
|
+
import { styled as fe } from "@arcblock/ux/lib/Theme";
|
|
17
17
|
import Ie from "lodash/cloneDeep";
|
|
18
|
-
import { joinURL as P, getQuery as
|
|
19
|
-
import { isSupportFollow as
|
|
18
|
+
import { joinURL as P, getQuery as Ne, withoutTrailingSlash as oe, withQuery as ne } from "ufo";
|
|
19
|
+
import { isSupportFollow as je } from "@arcblock/ux/lib/Util";
|
|
20
20
|
import { PROFILE_URL as S } from "@arcblock/ux/lib/Util/constant";
|
|
21
|
-
import
|
|
22
|
-
import
|
|
21
|
+
import He from "../../Footer/index.js";
|
|
22
|
+
import se from "../../Header/index.js";
|
|
23
23
|
import { translations as Ee } from "../libs/locales.js";
|
|
24
|
-
import
|
|
24
|
+
import le from "./user-info/user-basic-info.js";
|
|
25
25
|
import "@mui/icons-material";
|
|
26
26
|
import "@iconify/react";
|
|
27
27
|
import "@arcblock/ux/lib/DID";
|
|
@@ -35,14 +35,14 @@ import "./user-info/switch-role.js";
|
|
|
35
35
|
import { formatBlockletInfo as _e, getLink as M, getLocalizedNavigation as Oe } from "../../blocklets.js";
|
|
36
36
|
import Re from "./passport.js";
|
|
37
37
|
import $e from "./settings.js";
|
|
38
|
-
import { client as
|
|
38
|
+
import { client as ae } from "../../libs/client.js";
|
|
39
39
|
import qe from "../../hooks/use-mobile.js";
|
|
40
40
|
import { ConfigUserSpaceProvider as Ge } from "../../contexts/config-user-space.js";
|
|
41
41
|
import Qe from "./storage/index.js";
|
|
42
42
|
import Ve from "./nft.js";
|
|
43
|
-
import { UserFollowersProvider as
|
|
43
|
+
import { UserFollowersProvider as de } from "../../contexts/user-followers.js";
|
|
44
44
|
import Je from "./fallback.js";
|
|
45
|
-
const
|
|
45
|
+
const W = P(S, "/nfts"), A = P(S, "/settings"), L = P(S, "/did-spaces"), ce = P(S, "/user-followers"), ue = fe(l)(({ theme: v }) => ({
|
|
46
46
|
flex: 1,
|
|
47
47
|
boxSizing: "border-box",
|
|
48
48
|
padding: "0 16px",
|
|
@@ -56,7 +56,7 @@ const F = P(S, "/nfts"), z = P(S, "/settings"), W = P(S, "/did-spaces"), ue = P(
|
|
|
56
56
|
[v.breakpoints.up("md")]: {
|
|
57
57
|
flexDirection: "row"
|
|
58
58
|
}
|
|
59
|
-
})),
|
|
59
|
+
})), U = fe(l)(({ theme: v }) => ({
|
|
60
60
|
overflow: "hidden",
|
|
61
61
|
flex: "revert",
|
|
62
62
|
[v.breakpoints.up("md")]: {
|
|
@@ -70,44 +70,44 @@ const F = P(S, "/nfts"), z = P(S, "/settings"), W = P(S, "/did-spaces"), ue = P(
|
|
|
70
70
|
}));
|
|
71
71
|
function Or({
|
|
72
72
|
children: v,
|
|
73
|
-
notLoginContent:
|
|
73
|
+
notLoginContent: B = null,
|
|
74
74
|
currentTab: b,
|
|
75
|
-
contentProps:
|
|
76
|
-
disableAutoRedirect:
|
|
77
|
-
hideFooter:
|
|
78
|
-
headerProps:
|
|
79
|
-
footerProps:
|
|
75
|
+
contentProps: I = {},
|
|
76
|
+
disableAutoRedirect: N = !1,
|
|
77
|
+
hideFooter: pe = !1,
|
|
78
|
+
headerProps: me = {},
|
|
79
|
+
footerProps: he = {},
|
|
80
80
|
userDid: D = void 0,
|
|
81
|
-
stickySidebar:
|
|
82
|
-
embed:
|
|
81
|
+
stickySidebar: j = !1,
|
|
82
|
+
embed: H = !1,
|
|
83
83
|
onlyProfile: y = !1,
|
|
84
84
|
// 只显示 profile 页面,用于 ArcSphere 只需要显示 Profile 的内容
|
|
85
|
-
onDestroySelf:
|
|
85
|
+
onDestroySelf: xe = void 0
|
|
86
86
|
}) {
|
|
87
|
-
const { locale: h, defaultLocale: k } = Ue(),
|
|
87
|
+
const { locale: h, defaultLocale: k } = Ue(), a = qe({ key: "md" }), f = C((e, t = {}) => Le(Ee, e, h, "en", t)), o = ke(Fe)?.session, x = u(() => {
|
|
88
88
|
if (D)
|
|
89
89
|
return D;
|
|
90
|
-
const e = window.location.href, t =
|
|
90
|
+
const e = window.location.href, t = Ne(e);
|
|
91
91
|
return t?.did ? Array.isArray(t.did) ? t.did[0] : t.did : o?.user?.did;
|
|
92
|
-
}, [o?.user?.did, D]), i =
|
|
92
|
+
}, [o?.user?.did, D]), i = u(() => o?.user ? x === o?.user?.did : !1, [x, o?.user?.did]), w = Ce(() => je(), []), n = te(
|
|
93
93
|
// eslint-disable-next-line consistent-return
|
|
94
94
|
async () => {
|
|
95
95
|
if (await De(() => o?.initialized), i)
|
|
96
96
|
return o.user;
|
|
97
97
|
if (x)
|
|
98
|
-
return
|
|
98
|
+
return ae.user.getUserPublicInfo({ did: x });
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
101
|
refreshDeps: [x, i, o?.initialized, o?.user]
|
|
102
102
|
}
|
|
103
|
-
),
|
|
104
|
-
async () => n.data && b ? await
|
|
103
|
+
), E = C(() => i ? o.refresh() : n.refresh()), g = te(
|
|
104
|
+
async () => n.data && b ? await ae.user.getUserPrivacyConfig({ did: x }) : null,
|
|
105
105
|
{
|
|
106
106
|
refreshDeps: [x, n.data, b],
|
|
107
107
|
loadingDelay: 300
|
|
108
108
|
}
|
|
109
|
-
), { confirmHolder:
|
|
110
|
-
fullScreen:
|
|
109
|
+
), { confirmHolder: _ } = Ae({
|
|
110
|
+
fullScreen: a,
|
|
111
111
|
sx: {
|
|
112
112
|
".MuiDialog-paper": {
|
|
113
113
|
borderRadius: 1,
|
|
@@ -126,93 +126,93 @@ function Or({
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
}),
|
|
129
|
+
}), O = u(() => {
|
|
130
130
|
const e = Ie(window.blocklet);
|
|
131
131
|
try {
|
|
132
132
|
return _e(e);
|
|
133
133
|
} catch (t) {
|
|
134
134
|
return console.error("Failed to format blocklet info", t, e), e;
|
|
135
135
|
}
|
|
136
|
-
}, []),
|
|
136
|
+
}, []), R = u(() => {
|
|
137
137
|
const e = {
|
|
138
|
-
label:
|
|
138
|
+
label: f("common.nft"),
|
|
139
139
|
protected: !1,
|
|
140
140
|
isPrivate: !1,
|
|
141
141
|
// true: 隐私数据,仅自己可见
|
|
142
|
-
value:
|
|
143
|
-
url: M(
|
|
142
|
+
value: W,
|
|
143
|
+
url: M(W, h, k)
|
|
144
144
|
}, t = {
|
|
145
|
-
label:
|
|
145
|
+
label: f("userFollowers"),
|
|
146
146
|
protected: !1,
|
|
147
147
|
isPrivate: !1,
|
|
148
|
-
value:
|
|
149
|
-
url: M(
|
|
148
|
+
value: ce,
|
|
149
|
+
url: M(ce, h, k)
|
|
150
150
|
};
|
|
151
|
-
let
|
|
151
|
+
let p = w ? [e, t] : [e];
|
|
152
152
|
if (i) {
|
|
153
|
-
const
|
|
153
|
+
const c = [
|
|
154
154
|
e,
|
|
155
155
|
{
|
|
156
|
-
label:
|
|
156
|
+
label: f("common.setting"),
|
|
157
157
|
protected: !0,
|
|
158
158
|
isPrivate: !0,
|
|
159
|
-
value:
|
|
160
|
-
url: M(
|
|
159
|
+
value: A,
|
|
160
|
+
url: M(A, h, k)
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
|
-
label:
|
|
163
|
+
label: f("storageManagement"),
|
|
164
164
|
protected: !0,
|
|
165
165
|
isPrivate: !0,
|
|
166
|
-
value:
|
|
167
|
-
url: M(
|
|
166
|
+
value: L,
|
|
167
|
+
url: M(L, h, k)
|
|
168
168
|
}
|
|
169
169
|
];
|
|
170
|
-
|
|
170
|
+
p = w ? [...c, t] : c;
|
|
171
171
|
}
|
|
172
|
-
return
|
|
173
|
-
}, [i, h, w]),
|
|
174
|
-
const e =
|
|
175
|
-
return (Oe({ navigation: e, locale: h, defaultLocale: k }) || []).concat(
|
|
176
|
-
const
|
|
172
|
+
return p;
|
|
173
|
+
}, [i, h, w]), d = u(() => {
|
|
174
|
+
const e = O?.navigation?.userCenter || [];
|
|
175
|
+
return (Oe({ navigation: e, locale: h, defaultLocale: k }) || []).concat(R).map((c) => {
|
|
176
|
+
const Z = c.value ?? c._rawLink ?? c.link ?? c.url;
|
|
177
177
|
return {
|
|
178
|
-
value:
|
|
179
|
-
label:
|
|
180
|
-
url:
|
|
181
|
-
protected: g?.data?.[
|
|
182
|
-
isPrivate:
|
|
178
|
+
value: Z,
|
|
179
|
+
label: c.title || c.label,
|
|
180
|
+
url: c.link || c.url,
|
|
181
|
+
protected: g?.data?.[Z] ?? !1,
|
|
182
|
+
isPrivate: c.isPrivate || c.private || (c?._rawLink?.includes("/customer") ?? !1),
|
|
183
183
|
// FIXME: HACK: 隐藏 /customer 菜单, 需要一个通用的解决方案,在嵌入的时候就决定是否是私有的
|
|
184
|
-
followersOnly:
|
|
184
|
+
followersOnly: c.component === "did-comments"
|
|
185
185
|
// 是否开启仅粉丝可查看的功能,目前只对 discuss kit 开启
|
|
186
186
|
// icon: x.icon,
|
|
187
187
|
};
|
|
188
|
-
}).filter((
|
|
189
|
-
}, [
|
|
190
|
-
const e = window.blocklet?.appName,
|
|
191
|
-
return e ? `${
|
|
192
|
-
}, [s,
|
|
188
|
+
}).filter((c) => i || !c.isPrivate);
|
|
189
|
+
}, [O, n.data, g?.data, h, R, i]), s = u(() => d.find((e) => oe(e.value) === oe(b)), [d]), $ = u(() => {
|
|
190
|
+
const e = window.blocklet?.appName, p = [s?.label, f("userCenter.title")].filter(Boolean).join("-");
|
|
191
|
+
return e ? `${p} | ${e}` : p;
|
|
192
|
+
}, [s, f]), ge = C((e) => e && (ee(e) ? re(e, {
|
|
193
193
|
...e.props || {},
|
|
194
|
-
userCenterTabs:
|
|
195
|
-
}) :
|
|
194
|
+
userCenterTabs: d
|
|
195
|
+
}) : Pe.map(e, (t) => ee(t) ? re(t, {
|
|
196
196
|
...t.props || {},
|
|
197
|
-
userCenterTabs:
|
|
198
|
-
}) : t))),
|
|
199
|
-
const t =
|
|
200
|
-
t && (window.location.href =
|
|
197
|
+
userCenterTabs: d
|
|
198
|
+
}) : t))), be = C((e) => {
|
|
199
|
+
const t = d.find((p) => p.value === e);
|
|
200
|
+
t && (window.location.href = ne(t.url, {
|
|
201
201
|
did: i ? void 0 : x
|
|
202
202
|
}));
|
|
203
|
-
}),
|
|
203
|
+
}), q = u(() => /* @__PURE__ */ r(
|
|
204
204
|
$e,
|
|
205
205
|
{
|
|
206
206
|
user: n.data,
|
|
207
|
-
settings: { userCenterTabs:
|
|
207
|
+
settings: { userCenterTabs: d },
|
|
208
208
|
onSave: async (e) => e === "privacy" ? (await g.runAsync(), g.data) : (e === "profile" && await o.refresh(), null),
|
|
209
|
-
isMobile:
|
|
210
|
-
onDestroySelf:
|
|
209
|
+
isMobile: a,
|
|
210
|
+
onDestroySelf: xe
|
|
211
211
|
}
|
|
212
|
-
), [n.data,
|
|
213
|
-
o?.user?.sourceProvider === "passkey" ?
|
|
214
|
-
}),
|
|
215
|
-
|
|
212
|
+
), [n.data, d, g.data, g.runAsync]), G = u(() => s && s?.value === A, [s]), Q = u(() => s && s?.value === P(S, "/profile") || s?.value === W, [s]), ve = u(() => s && s?.value === L, [s]), we = o.useOAuth(), ye = o.usePasskey(), V = C(() => {
|
|
213
|
+
o?.user?.sourceProvider === "passkey" ? ye.switchPassport(o.user) : ["google", "apple", "email", "github"].includes(o?.user?.sourceProvider ?? "") ? we.switchOAuthPassport(o.user) : o && o.switchPassport();
|
|
214
|
+
}), F = u(() => Q ? /* @__PURE__ */ m(
|
|
215
|
+
l,
|
|
216
216
|
{
|
|
217
217
|
sx: {
|
|
218
218
|
display: "flex",
|
|
@@ -220,16 +220,16 @@ function Or({
|
|
|
220
220
|
gap: 2.5
|
|
221
221
|
},
|
|
222
222
|
children: [
|
|
223
|
-
i ? /* @__PURE__ */ m(
|
|
223
|
+
i ? /* @__PURE__ */ m(l, { sx: { border: "1px solid", borderColor: "divider", borderRadius: 1.5, p: 2 }, children: [
|
|
224
224
|
/* @__PURE__ */ r(
|
|
225
|
-
|
|
225
|
+
T,
|
|
226
226
|
{
|
|
227
227
|
sx: {
|
|
228
228
|
color: "text.primary",
|
|
229
229
|
fontWeight: 600,
|
|
230
230
|
mb: 2.5
|
|
231
231
|
},
|
|
232
|
-
children:
|
|
232
|
+
children: f("passport")
|
|
233
233
|
}
|
|
234
234
|
),
|
|
235
235
|
/* @__PURE__ */ r(Re, { user: n.data })
|
|
@@ -237,8 +237,8 @@ function Or({
|
|
|
237
237
|
/* @__PURE__ */ r(Ve, { user: n.data })
|
|
238
238
|
]
|
|
239
239
|
}
|
|
240
|
-
) :
|
|
241
|
-
|
|
240
|
+
) : G && i ? q : ve && i ? /* @__PURE__ */ r(Ge, { children: /* @__PURE__ */ r(Qe, {}) }) : null, [G, Q, n, i, j, q]), J = u(() => /* @__PURE__ */ r(
|
|
241
|
+
l,
|
|
242
242
|
{
|
|
243
243
|
sx: {
|
|
244
244
|
display: {
|
|
@@ -247,10 +247,10 @@ function Or({
|
|
|
247
247
|
},
|
|
248
248
|
py: 3
|
|
249
249
|
},
|
|
250
|
-
children: /* @__PURE__ */ r(
|
|
250
|
+
children: /* @__PURE__ */ r(z, { children: f("emptyContent") })
|
|
251
251
|
}
|
|
252
|
-
), [i, h]),
|
|
253
|
-
|
|
252
|
+
), [i, h]), K = u(() => !g.data || g.loading ? /* @__PURE__ */ r(
|
|
253
|
+
l,
|
|
254
254
|
{
|
|
255
255
|
sx: {
|
|
256
256
|
height: "100%",
|
|
@@ -263,27 +263,32 @@ function Or({
|
|
|
263
263
|
},
|
|
264
264
|
children: /* @__PURE__ */ r(Se, {})
|
|
265
265
|
}
|
|
266
|
-
) : /* @__PURE__ */ r(
|
|
266
|
+
) : /* @__PURE__ */ r(l, { sx: { flex: 1 }, children: /* @__PURE__ */ r(
|
|
267
267
|
Je,
|
|
268
268
|
{
|
|
269
269
|
isSupportFollow: w,
|
|
270
270
|
currentActiveTab: s,
|
|
271
271
|
isMyself: i,
|
|
272
|
-
children: v ? /* @__PURE__ */ r(
|
|
272
|
+
children: v ? /* @__PURE__ */ r(l, { ...I, children: ge(v) }) : F
|
|
273
273
|
}
|
|
274
|
-
) }), [g, s, i, v,
|
|
274
|
+
) }), [g, s, i, v, I, F, h]), X = u(() => {
|
|
275
275
|
if (n.loading || o.loading)
|
|
276
276
|
return null;
|
|
277
|
+
if (!n.data && !n.loading)
|
|
278
|
+
return /* @__PURE__ */ r(z, { style: { width: "100%", paddingTop: 16 }, children: /* @__PURE__ */ m(l, { sx: { textAlign: "center", width: "100%" }, children: [
|
|
279
|
+
/* @__PURE__ */ r(T, { variant: "body1", sx: { fontSize: 18, fontWeight: 500 }, children: f("userNotFound") }),
|
|
280
|
+
/* @__PURE__ */ r(T, { variant: "body1", color: "text.secondary", children: f("userNotFoundDescription") })
|
|
281
|
+
] }) });
|
|
277
282
|
if (n.error) {
|
|
278
283
|
if (n.error?.response?.status === 404)
|
|
279
|
-
return /* @__PURE__ */ r(
|
|
280
|
-
const
|
|
284
|
+
return /* @__PURE__ */ r(l, { sx: { width: "100%" }, children: /* @__PURE__ */ r(We, { status: 404, description: f("noUserFound") }) });
|
|
285
|
+
const p = {
|
|
281
286
|
message: n.error.response?.data?.error || n.error.message || "error occurred"
|
|
282
287
|
};
|
|
283
|
-
return /* @__PURE__ */ r(
|
|
288
|
+
return /* @__PURE__ */ r(l, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Be, { error: p }) });
|
|
284
289
|
}
|
|
285
|
-
return !x && !n.data ?
|
|
286
|
-
|
|
290
|
+
return !x && !n.data ? B || /* @__PURE__ */ r(l, { sx: { width: "100%" }, children: /* @__PURE__ */ m(
|
|
291
|
+
l,
|
|
287
292
|
{
|
|
288
293
|
sx: {
|
|
289
294
|
display: "flex",
|
|
@@ -293,56 +298,56 @@ function Or({
|
|
|
293
298
|
gap: 1
|
|
294
299
|
},
|
|
295
300
|
children: [
|
|
296
|
-
/* @__PURE__ */ r(
|
|
297
|
-
/* @__PURE__ */ r(ze, { size: "small", variant: "contained", onClick: () => o.login(), children:
|
|
301
|
+
/* @__PURE__ */ r(z, { children: f("viewAfterLogin") }),
|
|
302
|
+
/* @__PURE__ */ r(ze, { size: "small", variant: "contained", onClick: () => o.login(), children: f("loginNow") })
|
|
298
303
|
]
|
|
299
304
|
}
|
|
300
|
-
) }) :
|
|
301
|
-
|
|
302
|
-
|
|
305
|
+
) }) : H ? /* @__PURE__ */ m(U, { children: [
|
|
306
|
+
d.length > 0 && b ? /* @__PURE__ */ r(
|
|
307
|
+
l,
|
|
303
308
|
{
|
|
304
309
|
sx: {
|
|
305
|
-
display:
|
|
310
|
+
display: a ? "block" : "flex",
|
|
306
311
|
height: "100%",
|
|
307
312
|
overflow: "auto",
|
|
308
313
|
padding: "1px"
|
|
309
314
|
},
|
|
310
|
-
children:
|
|
315
|
+
children: K
|
|
311
316
|
}
|
|
312
317
|
) : null,
|
|
313
|
-
|
|
314
|
-
] }) : y ? /* @__PURE__ */ r(
|
|
315
|
-
|
|
318
|
+
d.length === 0 && J
|
|
319
|
+
] }) : y ? /* @__PURE__ */ r(U, { display: "flex", flexDirection: a ? "column" : "row", children: /* @__PURE__ */ r(
|
|
320
|
+
le,
|
|
316
321
|
{
|
|
317
|
-
isMobile:
|
|
318
|
-
order:
|
|
322
|
+
isMobile: a,
|
|
323
|
+
order: a ? 1 : "unset",
|
|
319
324
|
isMyself: i,
|
|
320
|
-
switchPassport:
|
|
325
|
+
switchPassport: V,
|
|
321
326
|
switchProfile: o.switchProfile,
|
|
322
327
|
user: n.data,
|
|
323
328
|
showFullDid: !1,
|
|
324
329
|
onlyProfile: y,
|
|
325
|
-
refreshProfile:
|
|
330
|
+
refreshProfile: E,
|
|
326
331
|
isShowSocialActions: w,
|
|
327
332
|
sx: {
|
|
328
|
-
padding:
|
|
329
|
-
...
|
|
333
|
+
padding: a ? "16px 0 0 0" : "40px 24px 24px 40px",
|
|
334
|
+
...a ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
|
|
330
335
|
boxSizing: "content-box"
|
|
331
336
|
}
|
|
332
337
|
}
|
|
333
|
-
) }) : /* @__PURE__ */ m(
|
|
338
|
+
) }) : /* @__PURE__ */ m(U, { display: "flex", flexDirection: a ? "column" : "row", children: [
|
|
334
339
|
/* @__PURE__ */ m(
|
|
335
|
-
|
|
340
|
+
l,
|
|
336
341
|
{
|
|
337
342
|
className: "user-center-tabs",
|
|
338
343
|
sx: {
|
|
339
344
|
flex: "1",
|
|
340
|
-
order:
|
|
341
|
-
width:
|
|
345
|
+
order: a ? 2 : "unset",
|
|
346
|
+
width: a ? "unset" : "calc(100% - 424px)"
|
|
342
347
|
},
|
|
343
348
|
children: [
|
|
344
|
-
|
|
345
|
-
|
|
349
|
+
d.length > 0 && b ? /* @__PURE__ */ m(
|
|
350
|
+
l,
|
|
346
351
|
{
|
|
347
352
|
sx: {
|
|
348
353
|
display: "flex",
|
|
@@ -353,20 +358,20 @@ function Or({
|
|
|
353
358
|
},
|
|
354
359
|
children: [
|
|
355
360
|
/* @__PURE__ */ r(
|
|
356
|
-
|
|
361
|
+
Te,
|
|
357
362
|
{
|
|
358
363
|
orientation: "horizontal",
|
|
359
364
|
variant: "line",
|
|
360
|
-
tabs:
|
|
365
|
+
tabs: d,
|
|
361
366
|
current: s?.value ?? b,
|
|
362
|
-
onChange:
|
|
367
|
+
onChange: be,
|
|
363
368
|
enableTabClick: !0,
|
|
364
369
|
sx: {
|
|
365
370
|
mb: (e) => `${e.spacing(3)} !important`,
|
|
366
371
|
".MuiTabs-flexContainer": {
|
|
367
372
|
gap: 3,
|
|
368
373
|
".MuiButtonBase-root": {
|
|
369
|
-
padding:
|
|
374
|
+
padding: a ? "16px 4px" : "32px 4px 16px 4px",
|
|
370
375
|
fontSize: 16
|
|
371
376
|
},
|
|
372
377
|
".MuiTab-root": {
|
|
@@ -396,30 +401,30 @@ function Or({
|
|
|
396
401
|
}
|
|
397
402
|
}
|
|
398
403
|
),
|
|
399
|
-
|
|
404
|
+
K
|
|
400
405
|
]
|
|
401
406
|
}
|
|
402
407
|
) : null,
|
|
403
|
-
|
|
408
|
+
d.length === 0 && J
|
|
404
409
|
]
|
|
405
410
|
}
|
|
406
411
|
),
|
|
407
|
-
!
|
|
412
|
+
!a && /* @__PURE__ */ r(Me, { orientation: "vertical", sx: { ml: 5 } }),
|
|
408
413
|
/* @__PURE__ */ r(
|
|
409
|
-
|
|
414
|
+
le,
|
|
410
415
|
{
|
|
411
|
-
isMobile:
|
|
412
|
-
order:
|
|
416
|
+
isMobile: a,
|
|
417
|
+
order: a ? 1 : "unset",
|
|
413
418
|
isMyself: i,
|
|
414
|
-
switchPassport:
|
|
419
|
+
switchPassport: V,
|
|
415
420
|
switchProfile: o.switchProfile,
|
|
416
421
|
user: n.data,
|
|
417
|
-
refreshProfile:
|
|
422
|
+
refreshProfile: E,
|
|
418
423
|
showFullDid: !1,
|
|
419
424
|
isShowSocialActions: w,
|
|
420
425
|
sx: {
|
|
421
|
-
padding:
|
|
422
|
-
...
|
|
426
|
+
padding: a ? "16px 0 0 0" : "40px 24px 24px 40px",
|
|
427
|
+
...a ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
|
|
423
428
|
boxSizing: "content-box"
|
|
424
429
|
}
|
|
425
430
|
}
|
|
@@ -427,31 +432,31 @@ function Or({
|
|
|
427
432
|
] });
|
|
428
433
|
}, [
|
|
429
434
|
n,
|
|
430
|
-
|
|
435
|
+
d,
|
|
431
436
|
i,
|
|
432
437
|
s,
|
|
433
438
|
g,
|
|
434
439
|
b,
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
]),
|
|
438
|
-
if (
|
|
439
|
-
const e =
|
|
440
|
+
j,
|
|
441
|
+
F
|
|
442
|
+
]), Y = u(() => i ? !1 : s?.isPrivate, [i, s]);
|
|
443
|
+
if (u(() => y ? !1 : !N && !b && d?.length > 0 || !s || Y, [N, b, d, s, Y, y])) {
|
|
444
|
+
const e = d[0]?.url, t = d.find((p) => p.value === e);
|
|
440
445
|
return e && !t?.isPrivate && window.location.replace(
|
|
441
|
-
|
|
446
|
+
ne(e, {
|
|
442
447
|
did: i ? void 0 : x
|
|
443
448
|
})
|
|
444
449
|
), null;
|
|
445
450
|
}
|
|
446
|
-
return
|
|
447
|
-
/* @__PURE__ */ r(
|
|
448
|
-
/* @__PURE__ */ r(
|
|
449
|
-
/* @__PURE__ */ m(
|
|
450
|
-
/* @__PURE__ */ r(
|
|
451
|
-
|
|
451
|
+
return H || y ? /* @__PURE__ */ m(l, { children: [
|
|
452
|
+
/* @__PURE__ */ r(ie, { children: /* @__PURE__ */ r("title", { children: $ }) }),
|
|
453
|
+
/* @__PURE__ */ r(se, { style: { display: "none" } }),
|
|
454
|
+
/* @__PURE__ */ m(ue, { children: [
|
|
455
|
+
/* @__PURE__ */ r(de, { isMySelf: i, userDid: n.data?.did ?? "", children: X }),
|
|
456
|
+
_
|
|
452
457
|
] })
|
|
453
458
|
] }) : /* @__PURE__ */ m(
|
|
454
|
-
|
|
459
|
+
l,
|
|
455
460
|
{
|
|
456
461
|
sx: {
|
|
457
462
|
minHeight: "100vh",
|
|
@@ -459,17 +464,17 @@ function Or({
|
|
|
459
464
|
flexDirection: "column"
|
|
460
465
|
},
|
|
461
466
|
children: [
|
|
462
|
-
/* @__PURE__ */ r(
|
|
463
|
-
/* @__PURE__ */ r(
|
|
464
|
-
/* @__PURE__ */ m(
|
|
465
|
-
/* @__PURE__ */ r(
|
|
466
|
-
|
|
467
|
+
/* @__PURE__ */ r(ie, { children: /* @__PURE__ */ r("title", { children: $ }) }),
|
|
468
|
+
/* @__PURE__ */ r(se, { bordered: !0, ...me, maxWidth: "100%" }),
|
|
469
|
+
/* @__PURE__ */ m(ue, { children: [
|
|
470
|
+
/* @__PURE__ */ r(de, { isMySelf: i, userDid: n.data?.did ?? "", children: X }),
|
|
471
|
+
_
|
|
467
472
|
] }),
|
|
468
|
-
|
|
469
|
-
|
|
473
|
+
pe ? null : /* @__PURE__ */ r(
|
|
474
|
+
He,
|
|
470
475
|
{
|
|
471
476
|
bordered: !0,
|
|
472
|
-
...
|
|
477
|
+
...he,
|
|
473
478
|
sx: {
|
|
474
479
|
".MuiContainer-root": {
|
|
475
480
|
maxWidth: 1600
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as d, jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import { Box as p } from "@mui/material";
|
|
3
3
|
import { useMemoizedFn as u } from "ahooks";
|
|
4
|
-
import { translate as
|
|
5
|
-
import { useLocaleContext as
|
|
6
|
-
import
|
|
7
|
-
import { translations as
|
|
4
|
+
import { translate as m } from "@arcblock/ux/lib/Locale/util";
|
|
5
|
+
import { useLocaleContext as f } from "@arcblock/ux/lib/Locale/context";
|
|
6
|
+
import x from "@arcblock/ux/lib/PhoneInput/country-select";
|
|
7
|
+
import { translations as y } from "../../libs/locales.js";
|
|
8
8
|
import n from "../editable-field.js";
|
|
9
|
-
const
|
|
9
|
+
const b = {
|
|
10
10
|
width: "100%",
|
|
11
11
|
px: 2,
|
|
12
12
|
py: 1,
|
|
@@ -26,14 +26,14 @@ const v = {
|
|
|
26
26
|
alignItems: "center"
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
function
|
|
29
|
+
function E({
|
|
30
30
|
address: r,
|
|
31
31
|
errors: t,
|
|
32
32
|
handleChange: i,
|
|
33
|
-
defaultCountry:
|
|
33
|
+
defaultCountry: a
|
|
34
34
|
}) {
|
|
35
|
-
const { locale: s } =
|
|
36
|
-
return /* @__PURE__ */
|
|
35
|
+
const { locale: s } = f(), o = u((e, c = {}) => m(y, e, s, "en", c));
|
|
36
|
+
return /* @__PURE__ */ d(
|
|
37
37
|
p,
|
|
38
38
|
{
|
|
39
39
|
sx: {
|
|
@@ -47,26 +47,26 @@ function I({
|
|
|
47
47
|
n,
|
|
48
48
|
{
|
|
49
49
|
placeholder: o("profile.address.country"),
|
|
50
|
-
value: r.country ||
|
|
50
|
+
value: r.country || a,
|
|
51
51
|
editable: !0,
|
|
52
52
|
errorMsg: t.country,
|
|
53
53
|
label: o("profile.address.country"),
|
|
54
54
|
children: /* @__PURE__ */ l(
|
|
55
|
-
|
|
55
|
+
x,
|
|
56
56
|
{
|
|
57
|
-
value: r.country ||
|
|
57
|
+
value: r.country || a,
|
|
58
58
|
onChange: (e) => i("country", e),
|
|
59
59
|
displayEmpty: !0,
|
|
60
60
|
variant: "outlined",
|
|
61
61
|
selectCountryProps: {
|
|
62
62
|
hideDialCode: !0
|
|
63
63
|
},
|
|
64
|
-
sx:
|
|
64
|
+
sx: b
|
|
65
65
|
}
|
|
66
66
|
)
|
|
67
67
|
}
|
|
68
68
|
),
|
|
69
|
-
/* @__PURE__ */
|
|
69
|
+
/* @__PURE__ */ d(
|
|
70
70
|
p,
|
|
71
71
|
{
|
|
72
72
|
sx: {
|
|
@@ -82,6 +82,7 @@ function I({
|
|
|
82
82
|
placeholder: o("profile.address.province"),
|
|
83
83
|
label: o("profile.address.province"),
|
|
84
84
|
editable: !0,
|
|
85
|
+
maxLength: 50,
|
|
85
86
|
errorMsg: t.province
|
|
86
87
|
}
|
|
87
88
|
),
|
|
@@ -93,6 +94,7 @@ function I({
|
|
|
93
94
|
placeholder: o("profile.address.city"),
|
|
94
95
|
label: o("profile.address.city"),
|
|
95
96
|
editable: !0,
|
|
97
|
+
maxLength: 50,
|
|
96
98
|
errorMsg: t.city
|
|
97
99
|
}
|
|
98
100
|
)
|
|
@@ -108,6 +110,7 @@ function I({
|
|
|
108
110
|
label: o("profile.address.line1"),
|
|
109
111
|
component: "textarea",
|
|
110
112
|
editable: !0,
|
|
113
|
+
maxLength: 200,
|
|
111
114
|
rows: 2,
|
|
112
115
|
errorMsg: t.line1
|
|
113
116
|
}
|
|
@@ -122,6 +125,7 @@ function I({
|
|
|
122
125
|
component: "textarea",
|
|
123
126
|
editable: !0,
|
|
124
127
|
rows: 2,
|
|
128
|
+
maxLength: 200,
|
|
125
129
|
errorMsg: t.line2
|
|
126
130
|
}
|
|
127
131
|
),
|
|
@@ -133,6 +137,7 @@ function I({
|
|
|
133
137
|
placeholder: o("profile.address.postalCode"),
|
|
134
138
|
label: o("profile.address.postalCode"),
|
|
135
139
|
editable: !0,
|
|
140
|
+
maxLength: 20,
|
|
136
141
|
errorMsg: t.postalCode
|
|
137
142
|
}
|
|
138
143
|
)
|
|
@@ -141,5 +146,5 @@ function I({
|
|
|
141
146
|
);
|
|
142
147
|
}
|
|
143
148
|
export {
|
|
144
|
-
|
|
149
|
+
E as default
|
|
145
150
|
};
|
|
@@ -181,6 +181,8 @@ export declare const translations: {
|
|
|
181
181
|
userCenter: {
|
|
182
182
|
title: string;
|
|
183
183
|
};
|
|
184
|
+
userNotFound: string;
|
|
185
|
+
userNotFoundDescription: string;
|
|
184
186
|
};
|
|
185
187
|
en: {
|
|
186
188
|
settings: string;
|
|
@@ -365,5 +367,7 @@ export declare const translations: {
|
|
|
365
367
|
userCenter: {
|
|
366
368
|
title: string;
|
|
367
369
|
};
|
|
370
|
+
userNotFound: string;
|
|
371
|
+
userNotFoundDescription: string;
|
|
368
372
|
};
|
|
369
373
|
};
|
|
@@ -180,7 +180,9 @@ const e = {
|
|
|
180
180
|
notImplemented: "操作未实现",
|
|
181
181
|
userCenter: {
|
|
182
182
|
title: "用户中心"
|
|
183
|
-
}
|
|
183
|
+
},
|
|
184
|
+
userNotFound: "用户不存在",
|
|
185
|
+
userNotFoundDescription: "该账户已被管理员停用或移除。"
|
|
184
186
|
},
|
|
185
187
|
en: {
|
|
186
188
|
settings: "Settings",
|
|
@@ -364,7 +366,9 @@ const e = {
|
|
|
364
366
|
notImplemented: "This action is not implemented",
|
|
365
367
|
userCenter: {
|
|
366
368
|
title: "User Center"
|
|
367
|
-
}
|
|
369
|
+
},
|
|
370
|
+
userNotFound: "User not found",
|
|
371
|
+
userNotFoundDescription: "The account has been deactivated or removed by the administrator."
|
|
368
372
|
}
|
|
369
373
|
};
|
|
370
374
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.57",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@abtnode/constant": "1.17.0-beta-20251104-112713-e947b159",
|
|
37
37
|
"@abtnode/util": "1.17.0-beta-20251104-112713-e947b159",
|
|
38
|
-
"@arcblock/bridge": "3.1.
|
|
39
|
-
"@arcblock/icons": "3.1.
|
|
40
|
-
"@arcblock/react-hooks": "3.1.
|
|
38
|
+
"@arcblock/bridge": "3.1.57",
|
|
39
|
+
"@arcblock/icons": "3.1.57",
|
|
40
|
+
"@arcblock/react-hooks": "3.1.57",
|
|
41
41
|
"@arcblock/ws": "^1.27.2",
|
|
42
42
|
"@blocklet/constant": "1.17.0-beta-20251104-112713-e947b159",
|
|
43
43
|
"@blocklet/did-space-react": "^1.2.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"access": "public"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@arcblock/did-connect-react": "3.1.
|
|
86
|
+
"@arcblock/did-connect-react": "3.1.57",
|
|
87
87
|
"@types/dompurify": "^3.2.0",
|
|
88
88
|
"@types/ua-parser-js": "^0.7.39",
|
|
89
89
|
"@types/validator": "^13.15.2",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"jest": "^29.7.0",
|
|
92
92
|
"unbuild": "^2.0.0"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "ff0e37a8ddeb14f0ebd4e1d55a308b17041e4d70"
|
|
95
95
|
}
|
|
@@ -461,6 +461,22 @@ export default function UserCenter({
|
|
|
461
461
|
if (userState.loading || session.loading) {
|
|
462
462
|
return null;
|
|
463
463
|
}
|
|
464
|
+
|
|
465
|
+
if (!userState.data && !userState.loading) {
|
|
466
|
+
return (
|
|
467
|
+
<Empty style={{ width: '100%', paddingTop: 16 }}>
|
|
468
|
+
<Box sx={{ textAlign: 'center', width: '100%' }}>
|
|
469
|
+
<Typography variant="body1" sx={{ fontSize: 18, fontWeight: 500 }}>
|
|
470
|
+
{t('userNotFound')}
|
|
471
|
+
</Typography>
|
|
472
|
+
<Typography variant="body1" color="text.secondary">
|
|
473
|
+
{t('userNotFoundDescription')}
|
|
474
|
+
</Typography>
|
|
475
|
+
</Box>
|
|
476
|
+
</Empty>
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
|
|
464
480
|
if (userState.error) {
|
|
465
481
|
const errorStatus = (userState.error as AxiosError<{ error: string }>)?.response?.status;
|
|
466
482
|
if (errorStatus === 404) {
|
|
@@ -93,6 +93,7 @@ export default function AddressEditor({
|
|
|
93
93
|
placeholder={t('profile.address.province')}
|
|
94
94
|
label={t('profile.address.province')}
|
|
95
95
|
editable
|
|
96
|
+
maxLength={50}
|
|
96
97
|
errorMsg={errors.province}
|
|
97
98
|
/>
|
|
98
99
|
|
|
@@ -102,6 +103,7 @@ export default function AddressEditor({
|
|
|
102
103
|
placeholder={t('profile.address.city')}
|
|
103
104
|
label={t('profile.address.city')}
|
|
104
105
|
editable
|
|
106
|
+
maxLength={50}
|
|
105
107
|
errorMsg={errors.city}
|
|
106
108
|
/>
|
|
107
109
|
</Box>
|
|
@@ -112,6 +114,7 @@ export default function AddressEditor({
|
|
|
112
114
|
label={t('profile.address.line1')}
|
|
113
115
|
component="textarea"
|
|
114
116
|
editable
|
|
117
|
+
maxLength={200}
|
|
115
118
|
rows={2}
|
|
116
119
|
errorMsg={errors.line1}
|
|
117
120
|
/>
|
|
@@ -123,6 +126,7 @@ export default function AddressEditor({
|
|
|
123
126
|
component="textarea"
|
|
124
127
|
editable
|
|
125
128
|
rows={2}
|
|
129
|
+
maxLength={200}
|
|
126
130
|
errorMsg={errors.line2}
|
|
127
131
|
/>
|
|
128
132
|
<EditableField
|
|
@@ -131,6 +135,7 @@ export default function AddressEditor({
|
|
|
131
135
|
placeholder={t('profile.address.postalCode')}
|
|
132
136
|
label={t('profile.address.postalCode')}
|
|
133
137
|
editable
|
|
138
|
+
maxLength={20}
|
|
134
139
|
errorMsg={errors.postalCode}
|
|
135
140
|
/>
|
|
136
141
|
</Box>
|
|
@@ -183,6 +183,8 @@ export const translations = {
|
|
|
183
183
|
userCenter: {
|
|
184
184
|
title: '用户中心',
|
|
185
185
|
},
|
|
186
|
+
userNotFound: '用户不存在',
|
|
187
|
+
userNotFoundDescription: '该账户已被管理员停用或移除。',
|
|
186
188
|
},
|
|
187
189
|
en: {
|
|
188
190
|
settings: 'Settings',
|
|
@@ -370,5 +372,7 @@ export const translations = {
|
|
|
370
372
|
userCenter: {
|
|
371
373
|
title: 'User Center',
|
|
372
374
|
},
|
|
375
|
+
userNotFound: 'User not found',
|
|
376
|
+
userNotFoundDescription: 'The account has been deactivated or removed by the administrator.',
|
|
373
377
|
},
|
|
374
378
|
};
|