@blocklet/ui-react 3.3.10 → 3.4.1
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/Dashboard/app-shell/badges/app-badge-default.d.ts +1 -1
- package/lib/Dashboard/index.d.ts +2 -2
- package/lib/Footer/links.d.ts +1 -1
- package/lib/Notifications/utils.js +29 -29
- package/lib/UserCenter/components/config-inviter.js +12 -12
- package/lib/UserCenter/components/config-profile.js +22 -22
- package/lib/UserCenter/components/nft-preview.js +1 -1
- package/lib/UserCenter/components/notification.js +59 -59
- package/lib/UserCenter/components/privacy.js +16 -16
- package/lib/UserCenter/components/settings.js +34 -34
- package/lib/UserCenter/components/storage/icons/empty-spaces-nft.svg.js +2 -2
- package/lib/UserCenter/components/user-center.js +68 -68
- package/lib/UserCenter/components/user-info/user-basic-info.js +52 -52
- package/lib/UserSessions/components/user-sessions.js +36 -36
- package/lib/blocklets.d.ts +1 -1
- package/lib/common/header-addons.d.ts +1 -1
- package/lib/common/org-switch/create.js +22 -26
- package/lib/common/org-switch/use-org.js +16 -16
- package/lib/hooks/use-follow.js +21 -21
- package/package.json +8 -8
- package/src/Dashboard/app-shell/badges/app-badge-default.tsx +1 -2
- package/src/Notifications/utils.ts +2 -1
- package/src/UserCenter/components/config-inviter.tsx +2 -1
- package/src/UserCenter/components/config-profile.tsx +2 -1
- package/src/UserCenter/components/nft-preview.tsx +1 -1
- package/src/UserCenter/components/notification.tsx +2 -1
- package/src/UserCenter/components/privacy.tsx +2 -1
- package/src/UserCenter/components/settings.tsx +3 -1
- package/src/UserCenter/components/storage/icons/empty-spaces-nft.svg +1 -58
- package/src/UserCenter/components/user-center.tsx +2 -2
- package/src/UserCenter/components/user-info/user-basic-info.tsx +2 -1
- package/src/UserSessions/components/user-sessions.tsx +2 -2
- package/src/common/org-switch/create.jsx +2 -6
- package/src/common/org-switch/use-org.jsx +2 -1
- package/src/hooks/use-follow.tsx +2 -1
- package/lib/libs/client.d.ts +0 -2
- package/lib/libs/client.js +0 -5
- package/src/libs/client.ts +0 -4
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as r, jsxs as m } from "react/jsx-runtime";
|
|
2
|
-
import { use as ke, useMemo as Pe, isValidElement as
|
|
2
|
+
import { use as ke, useMemo as Pe, isValidElement as ie, cloneElement as oe, Children as Se } from "react";
|
|
3
3
|
import { Box as a, Typography as B, CircularProgress as Me, Divider as De } from "@mui/material";
|
|
4
|
-
import { useMemoizedFn as P, useCreation as d, useRequest as
|
|
4
|
+
import { useMemoizedFn as P, useCreation as d, useRequest as ne } from "ahooks";
|
|
5
5
|
import Fe from "p-wait-for";
|
|
6
|
-
import
|
|
6
|
+
import se from "react-helmet";
|
|
7
7
|
import { SessionContext as Te } from "@arcblock/did-connect-react/lib/Session";
|
|
8
8
|
import ze from "@arcblock/ux/lib/Tabs";
|
|
9
9
|
import I from "@arcblock/ux/lib/Empty";
|
|
@@ -15,13 +15,14 @@ import { useLocaleContext as Be } from "@arcblock/ux/lib/Locale/context";
|
|
|
15
15
|
import { ErrorFallback as Ie } from "@arcblock/ux/lib/ErrorBoundary";
|
|
16
16
|
import { styled as pe } from "@arcblock/ux/lib/Theme";
|
|
17
17
|
import Ne from "lodash/cloneDeep";
|
|
18
|
-
import { joinURL as S, getQuery as je, withoutTrailingSlash as
|
|
19
|
-
import {
|
|
18
|
+
import { joinURL as S, getQuery as je, withoutTrailingSlash as le, withQuery as ae } from "ufo";
|
|
19
|
+
import { getBlockletSDK as He } from "@blocklet/js-sdk";
|
|
20
|
+
import { isSupportFollow as Ee } from "@arcblock/ux/lib/Util";
|
|
20
21
|
import { PROFILE_URL as M } from "@arcblock/ux/lib/Util/constant";
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import { translations as
|
|
24
|
-
import
|
|
22
|
+
import _e from "../../Footer/index.js";
|
|
23
|
+
import ue from "../../Header/index.js";
|
|
24
|
+
import { translations as Oe } from "../libs/locales.js";
|
|
25
|
+
import de from "./user-info/user-basic-info.js";
|
|
25
26
|
import "@mui/icons-material";
|
|
26
27
|
import "@iconify/react";
|
|
27
28
|
import "@arcblock/ux/lib/DID";
|
|
@@ -32,17 +33,16 @@ import "@iconify-icons/material-symbols/settings-input-antenna-rounded";
|
|
|
32
33
|
import "@arcblock/ux/lib/RelativeTime";
|
|
33
34
|
import "@arcblock/ux/lib/UserCard/Content/shorten-label";
|
|
34
35
|
import "./user-info/switch-role.js";
|
|
35
|
-
import { formatBlockletInfo as
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import { ConfigUserSpaceProvider as Qe } from "../../contexts/config-user-space.js";
|
|
36
|
+
import { formatBlockletInfo as Re, getLink as F, getLocalizedNavigation as $e } from "../../blocklets.js";
|
|
37
|
+
import qe from "./passport.js";
|
|
38
|
+
import Ge from "./settings.js";
|
|
39
|
+
import Qe from "../../hooks/use-mobile.js";
|
|
40
|
+
import { ConfigUserSpaceProvider as Ke } from "../../contexts/config-user-space.js";
|
|
41
41
|
import Ve from "./storage/index.js";
|
|
42
42
|
import Je from "./nft.js";
|
|
43
43
|
import { UserFollowersProvider as ce } from "../../contexts/user-followers.js";
|
|
44
|
-
import
|
|
45
|
-
const T = S(M, "/nfts"), z = S(M, "/settings"), W = S(M, "/did-spaces"), j = S(M, "/user-followers"),
|
|
44
|
+
import Xe from "./fallback.js";
|
|
45
|
+
const T = S(M, "/nfts"), z = S(M, "/settings"), W = S(M, "/did-spaces"), j = S(M, "/user-followers"), Ye = (b) => b.some(
|
|
46
46
|
(y) => ["/userCenter/nfts", "/userCenter/user-followers", "/userCenter/settings", "/userCenter/did-spaces"].includes(
|
|
47
47
|
y.id
|
|
48
48
|
) || [T, z, W, j].includes(y.link)
|
|
@@ -72,7 +72,7 @@ const T = S(M, "/nfts"), z = S(M, "/settings"), W = S(M, "/did-spaces"), j = S(M
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}));
|
|
75
|
-
function
|
|
75
|
+
function qr({
|
|
76
76
|
children: b,
|
|
77
77
|
notLoginContent: y = null,
|
|
78
78
|
currentTab: v,
|
|
@@ -88,29 +88,29 @@ function $r({
|
|
|
88
88
|
// 只显示 profile 页面,用于 ArcSphere 只需要显示 Profile 的内容
|
|
89
89
|
onDestroySelf: ge = void 0
|
|
90
90
|
}) {
|
|
91
|
-
const { locale: x, defaultLocale: k } = Be(), u =
|
|
91
|
+
const O = He(), { locale: x, defaultLocale: k } = Be(), u = Qe({ key: "md" }), f = P((e, i = {}) => Ue(Oe, e, x, "en", i)), t = ke(Te)?.session, h = d(() => {
|
|
92
92
|
if (A)
|
|
93
93
|
return A;
|
|
94
94
|
const e = window.location.href, i = je(e);
|
|
95
95
|
return i?.did ? Array.isArray(i.did) ? i.did[0] : i.did : t?.user?.did;
|
|
96
|
-
}, [t?.user?.did, A]), o = d(() => t?.user ? h === t?.user?.did : !1, [h, t?.user?.did]), w = Pe(() => !!t?.user &&
|
|
96
|
+
}, [t?.user?.did, A]), o = d(() => t?.user ? h === t?.user?.did : !1, [h, t?.user?.did]), w = Pe(() => !!t?.user && Ee(), [t?.user]), n = ne(
|
|
97
97
|
// eslint-disable-next-line consistent-return
|
|
98
98
|
async () => {
|
|
99
99
|
if (await Fe(() => t?.initialized), o)
|
|
100
100
|
return t.user;
|
|
101
101
|
if (h)
|
|
102
|
-
return
|
|
102
|
+
return O.user.getUserPublicInfo({ did: h });
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
105
|
refreshDeps: [h, o, t?.initialized, t?.user]
|
|
106
106
|
}
|
|
107
|
-
),
|
|
108
|
-
async () => n.data && v ? await
|
|
107
|
+
), R = P(() => o ? t.refresh() : n.refresh()), g = ne(
|
|
108
|
+
async () => n.data && v ? await O.user.getUserPrivacyConfig({ did: h }) : null,
|
|
109
109
|
{
|
|
110
110
|
refreshDeps: [h, n.data, v],
|
|
111
111
|
loadingDelay: 300
|
|
112
112
|
}
|
|
113
|
-
), { confirmHolder:
|
|
113
|
+
), { confirmHolder: $ } = Le({
|
|
114
114
|
fullScreen: u,
|
|
115
115
|
sx: {
|
|
116
116
|
".MuiDialog-paper": {
|
|
@@ -130,14 +130,14 @@ function $r({
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
}),
|
|
133
|
+
}), q = d(() => {
|
|
134
134
|
const e = Ne(window.blocklet);
|
|
135
135
|
try {
|
|
136
|
-
return
|
|
136
|
+
return Re(e);
|
|
137
137
|
} catch (i) {
|
|
138
138
|
return console.error("Failed to format blocklet info", i, e), e;
|
|
139
139
|
}
|
|
140
|
-
}, []),
|
|
140
|
+
}, []), G = d(() => {
|
|
141
141
|
const e = {
|
|
142
142
|
label: f("common.nft"),
|
|
143
143
|
protected: !1,
|
|
@@ -175,14 +175,14 @@ function $r({
|
|
|
175
175
|
}
|
|
176
176
|
return p;
|
|
177
177
|
}, [o, x, w]), l = d(() => {
|
|
178
|
-
const e =
|
|
179
|
-
return (
|
|
180
|
-
const
|
|
178
|
+
const e = q?.navigation?.userCenter || [], i = Ye(e);
|
|
179
|
+
return ($e({ navigation: e, locale: x, defaultLocale: k }) || []).concat(i ? [] : G).map((c) => {
|
|
180
|
+
const te = c.value ?? c._rawLink ?? c.link ?? c.url;
|
|
181
181
|
return {
|
|
182
|
-
value:
|
|
182
|
+
value: te,
|
|
183
183
|
label: c.title || c.label,
|
|
184
184
|
url: c.link || c.url,
|
|
185
|
-
protected: g?.data?.[
|
|
185
|
+
protected: g?.data?.[te] ?? !1,
|
|
186
186
|
isPrivate: c.isPrivate || c.private || (c?._rawLink?.includes("/customer") ?? !1),
|
|
187
187
|
// FIXME: HACK: 隐藏 /customer 菜单, 需要一个通用的解决方案,在嵌入的时候就决定是否是私有的
|
|
188
188
|
followersOnly: c.component === "did-comments"
|
|
@@ -190,22 +190,22 @@ function $r({
|
|
|
190
190
|
// icon: x.icon,
|
|
191
191
|
};
|
|
192
192
|
}).filter((c) => o || !c.isPrivate);
|
|
193
|
-
}, [
|
|
193
|
+
}, [q, n.data, g?.data, x, G, o]), s = d(() => l.find((e) => le(e.value) === le(v)), [l]), Q = d(() => {
|
|
194
194
|
const e = window.blocklet?.appName, p = [s?.label, f("userCenter.title")].filter(Boolean).join("-");
|
|
195
195
|
return e ? `${p} | ${e}` : p;
|
|
196
|
-
}, [s, f]), be = P((e) => e && (
|
|
196
|
+
}, [s, f]), be = P((e) => e && (ie(e) ? oe(e, {
|
|
197
197
|
...e.props || {},
|
|
198
198
|
userCenterTabs: l
|
|
199
|
-
}) : Se.map(e, (i) =>
|
|
199
|
+
}) : Se.map(e, (i) => ie(i) ? oe(i, {
|
|
200
200
|
...i.props || {},
|
|
201
201
|
userCenterTabs: l
|
|
202
202
|
}) : i))), ve = P((e) => {
|
|
203
203
|
const i = l.find((p) => p.value === e);
|
|
204
|
-
i && (window.location.href =
|
|
204
|
+
i && (window.location.href = ae(i.url, {
|
|
205
205
|
did: o ? void 0 : h
|
|
206
206
|
}));
|
|
207
|
-
}),
|
|
208
|
-
|
|
207
|
+
}), K = d(() => /* @__PURE__ */ r(
|
|
208
|
+
Ge,
|
|
209
209
|
{
|
|
210
210
|
user: n.data,
|
|
211
211
|
settings: { userCenterTabs: l },
|
|
@@ -213,7 +213,7 @@ function $r({
|
|
|
213
213
|
isMobile: u,
|
|
214
214
|
onDestroySelf: ge
|
|
215
215
|
}
|
|
216
|
-
), [n.data, l, g.data, g.runAsync]), V = d(() => s && s?.value === z, [s]), J = d(() => s && s?.value === S(M, "/profile") || s?.value === T, [s]), we = d(() => s && s?.value === W, [s]), ye = t.useOAuth(), Ce = t.usePasskey(),
|
|
216
|
+
), [n.data, l, g.data, g.runAsync]), V = d(() => s && s?.value === z, [s]), J = d(() => s && s?.value === S(M, "/profile") || s?.value === T, [s]), we = d(() => s && s?.value === W, [s]), ye = t.useOAuth(), Ce = t.usePasskey(), X = P(() => {
|
|
217
217
|
t?.user?.sourceProvider === "passkey" ? Ce.switchPassport(t.user) : ["google", "apple", "email", "github"].includes(t?.user?.sourceProvider ?? "") ? ye.switchOAuthPassport(t.user) : t && t.switchPassport();
|
|
218
218
|
}), L = d(() => J ? /* @__PURE__ */ m(
|
|
219
219
|
a,
|
|
@@ -236,12 +236,12 @@ function $r({
|
|
|
236
236
|
children: f("passport")
|
|
237
237
|
}
|
|
238
238
|
),
|
|
239
|
-
/* @__PURE__ */ r(
|
|
239
|
+
/* @__PURE__ */ r(qe, { user: n.data })
|
|
240
240
|
] }) : null,
|
|
241
241
|
/* @__PURE__ */ r(Je, { user: n.data })
|
|
242
242
|
]
|
|
243
243
|
}
|
|
244
|
-
) : V && o ?
|
|
244
|
+
) : V && o ? K : we && o ? /* @__PURE__ */ r(Ke, { children: /* @__PURE__ */ r(Ve, {}) }) : null, [V, J, n, o, _, K]), Y = d(() => /* @__PURE__ */ r(
|
|
245
245
|
a,
|
|
246
246
|
{
|
|
247
247
|
sx: {
|
|
@@ -253,7 +253,7 @@ function $r({
|
|
|
253
253
|
},
|
|
254
254
|
children: /* @__PURE__ */ r(I, { children: f("emptyContent") })
|
|
255
255
|
}
|
|
256
|
-
), [o, x]),
|
|
256
|
+
), [o, x]), Z = d(() => !g.data || g.loading ? /* @__PURE__ */ r(
|
|
257
257
|
a,
|
|
258
258
|
{
|
|
259
259
|
sx: {
|
|
@@ -268,14 +268,14 @@ function $r({
|
|
|
268
268
|
children: /* @__PURE__ */ r(Me, {})
|
|
269
269
|
}
|
|
270
270
|
) : /* @__PURE__ */ r(a, { sx: { flex: 1 }, children: /* @__PURE__ */ r(
|
|
271
|
-
|
|
271
|
+
Xe,
|
|
272
272
|
{
|
|
273
273
|
isSupportFollow: w,
|
|
274
274
|
currentActiveTab: s,
|
|
275
275
|
isMyself: o,
|
|
276
276
|
children: b ? /* @__PURE__ */ r(a, { ...H, children: be(b) }) : L
|
|
277
277
|
}
|
|
278
|
-
) }), [g, s, o, b, H, L, x]),
|
|
278
|
+
) }), [g, s, o, b, H, L, x]), ee = d(() => {
|
|
279
279
|
if (n.loading || t.loading)
|
|
280
280
|
return null;
|
|
281
281
|
if (n.error) {
|
|
@@ -314,22 +314,22 @@ function $r({
|
|
|
314
314
|
overflow: "auto",
|
|
315
315
|
padding: "1px"
|
|
316
316
|
},
|
|
317
|
-
children:
|
|
317
|
+
children: Z
|
|
318
318
|
}
|
|
319
319
|
) : null,
|
|
320
|
-
l.length === 0 &&
|
|
320
|
+
l.length === 0 && Y
|
|
321
321
|
] }) : C ? /* @__PURE__ */ r(N, { display: "flex", flexDirection: u ? "column" : "row", children: /* @__PURE__ */ r(
|
|
322
|
-
|
|
322
|
+
de,
|
|
323
323
|
{
|
|
324
324
|
isMobile: u,
|
|
325
325
|
order: u ? 1 : "unset",
|
|
326
326
|
isMyself: o,
|
|
327
|
-
switchPassport:
|
|
327
|
+
switchPassport: X,
|
|
328
328
|
switchProfile: t.switchProfile,
|
|
329
329
|
user: n.data,
|
|
330
330
|
showFullDid: !1,
|
|
331
331
|
onlyProfile: C,
|
|
332
|
-
refreshProfile:
|
|
332
|
+
refreshProfile: R,
|
|
333
333
|
isShowSocialActions: w,
|
|
334
334
|
sx: {
|
|
335
335
|
padding: u ? "16px 0 0 0" : "40px 24px 24px 40px",
|
|
@@ -403,25 +403,25 @@ function $r({
|
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
405
|
),
|
|
406
|
-
|
|
406
|
+
Z
|
|
407
407
|
]
|
|
408
408
|
}
|
|
409
409
|
) : null,
|
|
410
|
-
l.length === 0 &&
|
|
410
|
+
l.length === 0 && Y
|
|
411
411
|
]
|
|
412
412
|
}
|
|
413
413
|
),
|
|
414
414
|
!u && /* @__PURE__ */ r(De, { orientation: "vertical", sx: { ml: 5 } }),
|
|
415
415
|
/* @__PURE__ */ r(
|
|
416
|
-
|
|
416
|
+
de,
|
|
417
417
|
{
|
|
418
418
|
isMobile: u,
|
|
419
419
|
order: u ? 1 : "unset",
|
|
420
420
|
isMyself: o,
|
|
421
|
-
switchPassport:
|
|
421
|
+
switchPassport: X,
|
|
422
422
|
switchProfile: t.switchProfile,
|
|
423
423
|
user: n.data,
|
|
424
|
-
refreshProfile:
|
|
424
|
+
refreshProfile: R,
|
|
425
425
|
showFullDid: !1,
|
|
426
426
|
isShowSocialActions: w,
|
|
427
427
|
sx: {
|
|
@@ -441,30 +441,30 @@ function $r({
|
|
|
441
441
|
v,
|
|
442
442
|
_,
|
|
443
443
|
L
|
|
444
|
-
]),
|
|
445
|
-
if (d(() => C || D || !l.length || !t.user ? !1 : !E && !v && l?.length > 0 || !s ||
|
|
444
|
+
]), re = d(() => o ? !1 : s?.isPrivate, [o, s]);
|
|
445
|
+
if (d(() => C || D || !l.length || !t.user ? !1 : !E && !v && l?.length > 0 || !s || re, [
|
|
446
446
|
E,
|
|
447
447
|
v,
|
|
448
448
|
l,
|
|
449
449
|
s,
|
|
450
|
-
|
|
450
|
+
re,
|
|
451
451
|
C,
|
|
452
452
|
t.user,
|
|
453
453
|
D
|
|
454
454
|
])) {
|
|
455
455
|
const e = l[0]?.url, i = l.find((p) => p.value === e);
|
|
456
456
|
return e && !i?.isPrivate && window.location.replace(
|
|
457
|
-
|
|
457
|
+
ae(e, {
|
|
458
458
|
did: o ? void 0 : h
|
|
459
459
|
})
|
|
460
460
|
), null;
|
|
461
461
|
}
|
|
462
462
|
return D || C ? /* @__PURE__ */ m(a, { children: [
|
|
463
|
-
/* @__PURE__ */ r(
|
|
464
|
-
/* @__PURE__ */ r(
|
|
463
|
+
/* @__PURE__ */ r(se, { children: /* @__PURE__ */ r("title", { children: Q }) }),
|
|
464
|
+
/* @__PURE__ */ r(ue, { style: { display: "none" } }),
|
|
465
465
|
/* @__PURE__ */ m(fe, { children: [
|
|
466
|
-
/* @__PURE__ */ r(ce, { isMySelf: o, userDid: n.data?.did ?? "", children:
|
|
467
|
-
|
|
466
|
+
/* @__PURE__ */ r(ce, { isMySelf: o, userDid: n.data?.did ?? "", children: ee }),
|
|
467
|
+
$
|
|
468
468
|
] })
|
|
469
469
|
] }) : /* @__PURE__ */ m(
|
|
470
470
|
a,
|
|
@@ -475,14 +475,14 @@ function $r({
|
|
|
475
475
|
flexDirection: "column"
|
|
476
476
|
},
|
|
477
477
|
children: [
|
|
478
|
-
/* @__PURE__ */ r(
|
|
479
|
-
/* @__PURE__ */ r(
|
|
478
|
+
/* @__PURE__ */ r(se, { children: /* @__PURE__ */ r("title", { children: Q }) }),
|
|
479
|
+
/* @__PURE__ */ r(ue, { bordered: !0, ...he, maxWidth: "100%" }),
|
|
480
480
|
/* @__PURE__ */ m(fe, { children: [
|
|
481
|
-
/* @__PURE__ */ r(ce, { isMySelf: o, userDid: n.data?.did ?? "", children:
|
|
482
|
-
|
|
481
|
+
/* @__PURE__ */ r(ce, { isMySelf: o, userDid: n.data?.did ?? "", children: ee }),
|
|
482
|
+
$
|
|
483
483
|
] }),
|
|
484
484
|
me ? null : /* @__PURE__ */ r(
|
|
485
|
-
|
|
485
|
+
_e,
|
|
486
486
|
{
|
|
487
487
|
bordered: !0,
|
|
488
488
|
...xe,
|
|
@@ -498,5 +498,5 @@ function $r({
|
|
|
498
498
|
);
|
|
499
499
|
}
|
|
500
500
|
export {
|
|
501
|
-
|
|
501
|
+
qr as default
|
|
502
502
|
};
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { jsxs as l, jsx as r, Fragment as
|
|
2
|
-
import { Box as s, Typography as
|
|
1
|
+
import { jsxs as l, jsx as r, Fragment as N } from "react/jsx-runtime";
|
|
2
|
+
import { Box as s, Typography as z, Divider as T, IconButton as F, Collapse as W } from "@mui/material";
|
|
3
3
|
import O from "@arcblock/ux/lib/Avatar";
|
|
4
4
|
import Q from "@arcblock/ux/lib/DID";
|
|
5
5
|
import { useMemoizedFn as V } from "ahooks";
|
|
6
6
|
import { translate as Y } from "@arcblock/ux/lib/Locale/util";
|
|
7
7
|
import { useLocaleContext as $ } from "@arcblock/ux/lib/Locale/context";
|
|
8
8
|
import q from "lodash/noop";
|
|
9
|
-
import { useState as
|
|
10
|
-
import
|
|
9
|
+
import { useState as C, useEffect as j } from "react";
|
|
10
|
+
import I from "@arcblock/ux/lib/Toast";
|
|
11
11
|
import { parseURL as G, joinURL as H } from "ufo";
|
|
12
12
|
import { KeyboardArrowUp as J, KeyboardArrowDown as X } from "@mui/icons-material";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import rt from "./
|
|
17
|
-
import et from "./
|
|
18
|
-
import ot from "./
|
|
19
|
-
import at from "./user-
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
function
|
|
13
|
+
import { getBlockletSDK as Z } from "@blocklet/js-sdk";
|
|
14
|
+
import { translations as _ } from "../../libs/locales.js";
|
|
15
|
+
import { formatAxiosError as R } from "../../libs/utils.js";
|
|
16
|
+
import { currentTimezone as P, getStatusDuration as M, isValidUrl as tt, isDuplicateUrl as rt } from "./utils.js";
|
|
17
|
+
import et from "./switch-role.js";
|
|
18
|
+
import ot from "./metadata.js";
|
|
19
|
+
import at from "./user-status.js";
|
|
20
|
+
import nt from "./user-info.js";
|
|
21
|
+
import it from "./social-actions/index.js";
|
|
22
|
+
function kt({
|
|
23
23
|
user: t,
|
|
24
24
|
isMyself: o = !0,
|
|
25
25
|
showFullDid: f = !0,
|
|
26
|
-
switchPassport:
|
|
27
|
-
switchProfile:
|
|
26
|
+
switchPassport: k,
|
|
27
|
+
switchProfile: A,
|
|
28
28
|
isMobile: a = !1,
|
|
29
29
|
onlyProfile: c = !1,
|
|
30
30
|
refreshProfile: u,
|
|
31
|
-
isShowSocialActions:
|
|
31
|
+
isShowSocialActions: D = !1,
|
|
32
32
|
...m
|
|
33
33
|
}) {
|
|
34
|
-
const { locale:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}, [t]),
|
|
38
|
-
|
|
34
|
+
const h = Z(), { locale: x } = $(), [g, v] = C(void 0), w = V((i, e = {}) => Y(_, i, x, "en", e)), [d, S] = C(!a || c);
|
|
35
|
+
j(() => {
|
|
36
|
+
v(t?.metadata?.status);
|
|
37
|
+
}, [t]), j(() => {
|
|
38
|
+
S(!a || c);
|
|
39
39
|
}, [a, c]);
|
|
40
|
-
const
|
|
40
|
+
const L = async (i) => {
|
|
41
41
|
if (o)
|
|
42
42
|
try {
|
|
43
43
|
if (i) {
|
|
44
|
-
const e =
|
|
45
|
-
i.dateRange = e.length > 0 ? e :
|
|
44
|
+
const e = M(i);
|
|
45
|
+
i.dateRange = e.length > 0 ? e : g?.dateRange ?? [];
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
v(i), await h.user.saveProfile({
|
|
48
48
|
// @ts-ignore
|
|
49
49
|
metadata: {
|
|
50
50
|
...t?.metadata ?? { joinedAt: t?.createdAt, email: t?.email, phone: t?.phone },
|
|
@@ -52,17 +52,17 @@ function Rt({
|
|
|
52
52
|
}
|
|
53
53
|
}), u();
|
|
54
54
|
} catch (e) {
|
|
55
|
-
console.error(e),
|
|
55
|
+
console.error(e), I.error(R(e));
|
|
56
56
|
}
|
|
57
57
|
}, b = () => {
|
|
58
|
-
|
|
59
|
-
},
|
|
58
|
+
S(!d);
|
|
59
|
+
}, B = async (i) => {
|
|
60
60
|
if (!o)
|
|
61
61
|
return;
|
|
62
|
-
const { metadata: e, address:
|
|
62
|
+
const { metadata: e, address: E } = i;
|
|
63
63
|
try {
|
|
64
|
-
const p = e?.links?.map((n,
|
|
65
|
-
if (!n.url || !
|
|
64
|
+
const p = e?.links?.map((n, U) => {
|
|
65
|
+
if (!n.url || !tt(n.url) || U > 0 && e.links?.slice(0, U)?.some((K) => rt(K.url, n.url)))
|
|
66
66
|
return null;
|
|
67
67
|
try {
|
|
68
68
|
return G(n.url).protocol || (n.url = H("https://", n.url)), n;
|
|
@@ -70,9 +70,9 @@ function Rt({
|
|
|
70
70
|
return console.error("Invalid URL:", n.url), null;
|
|
71
71
|
}
|
|
72
72
|
}).filter((n) => !!n) || [];
|
|
73
|
-
e.links = p, await
|
|
73
|
+
e.links = p, await h.user.saveProfile({ metadata: e, address: E }), u();
|
|
74
74
|
} catch (p) {
|
|
75
|
-
console.error(p),
|
|
75
|
+
console.error(p), I.error(R(p));
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
return /* @__PURE__ */ l(
|
|
@@ -122,7 +122,7 @@ function Rt({
|
|
|
122
122
|
...o ? {
|
|
123
123
|
cursor: "pointer",
|
|
124
124
|
"&::after": {
|
|
125
|
-
content: `"${
|
|
125
|
+
content: `"${w("switchProfile")}"`,
|
|
126
126
|
color: "white",
|
|
127
127
|
position: "absolute",
|
|
128
128
|
fontSize: "12px",
|
|
@@ -137,18 +137,18 @@ function Rt({
|
|
|
137
137
|
}
|
|
138
138
|
} : {}
|
|
139
139
|
},
|
|
140
|
-
onClick: o ?
|
|
140
|
+
onClick: o ? A : q
|
|
141
141
|
}
|
|
142
142
|
),
|
|
143
143
|
/* @__PURE__ */ r(
|
|
144
|
-
|
|
144
|
+
at,
|
|
145
145
|
{
|
|
146
146
|
isMobile: a,
|
|
147
147
|
size: m.size || (a ? 64 : 100),
|
|
148
148
|
isMyself: o,
|
|
149
|
-
timezone: t?.metadata?.timezone ||
|
|
150
|
-
status:
|
|
151
|
-
onChange:
|
|
149
|
+
timezone: t?.metadata?.timezone || P,
|
|
150
|
+
status: g,
|
|
151
|
+
onChange: L
|
|
152
152
|
}
|
|
153
153
|
)
|
|
154
154
|
]
|
|
@@ -163,7 +163,7 @@ function Rt({
|
|
|
163
163
|
},
|
|
164
164
|
children: [
|
|
165
165
|
/* @__PURE__ */ l(
|
|
166
|
-
|
|
166
|
+
z,
|
|
167
167
|
{
|
|
168
168
|
variant: "h6",
|
|
169
169
|
component: "div",
|
|
@@ -188,7 +188,7 @@ function Rt({
|
|
|
188
188
|
children: t?.fullName
|
|
189
189
|
}
|
|
190
190
|
),
|
|
191
|
-
o ? /* @__PURE__ */ r(
|
|
191
|
+
o ? /* @__PURE__ */ r(et, { user: t, switchPassport: k }) : null
|
|
192
192
|
]
|
|
193
193
|
}
|
|
194
194
|
),
|
|
@@ -201,7 +201,7 @@ function Rt({
|
|
|
201
201
|
copyable: !0,
|
|
202
202
|
compact: !f,
|
|
203
203
|
responsive: !f,
|
|
204
|
-
locale:
|
|
204
|
+
locale: x
|
|
205
205
|
}
|
|
206
206
|
)
|
|
207
207
|
]
|
|
@@ -210,10 +210,10 @@ function Rt({
|
|
|
210
210
|
]
|
|
211
211
|
}
|
|
212
212
|
),
|
|
213
|
-
!o &&
|
|
214
|
-
/* @__PURE__ */ r(
|
|
215
|
-
o ? /* @__PURE__ */ l(
|
|
216
|
-
/* @__PURE__ */ r(
|
|
213
|
+
!o && D ? /* @__PURE__ */ r(s, { sx: { mt: 2 }, children: /* @__PURE__ */ r(it, { user: t }) }) : null,
|
|
214
|
+
/* @__PURE__ */ r(ot, { isMobile: a, isMyself: o, user: t, onSave: B }),
|
|
215
|
+
o ? /* @__PURE__ */ l(N, { children: [
|
|
216
|
+
/* @__PURE__ */ r(T, { sx: { my: a ? 1 : 3 } }),
|
|
217
217
|
a && !c ? /* @__PURE__ */ r(
|
|
218
218
|
s,
|
|
219
219
|
{
|
|
@@ -223,7 +223,7 @@ function Rt({
|
|
|
223
223
|
mb: 0
|
|
224
224
|
},
|
|
225
225
|
children: /* @__PURE__ */ r(
|
|
226
|
-
|
|
226
|
+
F,
|
|
227
227
|
{
|
|
228
228
|
size: "small",
|
|
229
229
|
onClick: b,
|
|
@@ -241,7 +241,7 @@ function Rt({
|
|
|
241
241
|
) : null,
|
|
242
242
|
/* @__PURE__ */ l(W, { in: d, timeout: "auto", children: [
|
|
243
243
|
/* @__PURE__ */ r(
|
|
244
|
-
|
|
244
|
+
z,
|
|
245
245
|
{
|
|
246
246
|
component: "p",
|
|
247
247
|
sx: {
|
|
@@ -249,10 +249,10 @@ function Rt({
|
|
|
249
249
|
fontSize: "14px",
|
|
250
250
|
mb: 2
|
|
251
251
|
},
|
|
252
|
-
children:
|
|
252
|
+
children: w("profile.justForYou")
|
|
253
253
|
}
|
|
254
254
|
),
|
|
255
|
-
/* @__PURE__ */ r(
|
|
255
|
+
/* @__PURE__ */ r(nt, { user: t, isMySelf: o })
|
|
256
256
|
] })
|
|
257
257
|
] }) : null
|
|
258
258
|
]
|
|
@@ -260,5 +260,5 @@ function Rt({
|
|
|
260
260
|
);
|
|
261
261
|
}
|
|
262
262
|
export {
|
|
263
|
-
|
|
263
|
+
kt as default
|
|
264
264
|
};
|