@blocklet/ui-react 3.4.6 → 3.4.8
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-info/link-preview-input.js +5 -5
- package/lib/UserCenter/components/user-info/metadata.js +32 -30
- package/lib/UserCenter/components/user-info/user-basic-info.js +16 -16
- package/lib/common/header-addons.js +40 -48
- package/lib/common/org-switch/avatar-uploader.d.ts +30 -0
- package/lib/common/org-switch/avatar-uploader.js +170 -0
- package/lib/common/org-switch/create.d.ts +24 -4
- package/lib/common/org-switch/create.js +152 -91
- package/lib/common/org-switch/index.js +6 -6
- package/lib/common/org-switch/locales.d.ts +18 -0
- package/lib/common/org-switch/locales.js +16 -4
- package/lib/common/org-switch/use-org.d.ts +1 -0
- package/lib/common/org-switch/use-org.js +30 -23
- package/package.json +10 -8
- package/src/UserCenter/components/user-info/metadata.tsx +5 -3
- package/src/UserCenter/components/user-info/user-basic-info.tsx +4 -2
- package/src/common/header-addons.jsx +0 -17
- package/src/common/org-switch/avatar-uploader.jsx +271 -0
- package/src/common/org-switch/create.jsx +179 -55
- package/src/common/org-switch/index.jsx +1 -1
- package/src/common/org-switch/locales.js +12 -0
- package/src/common/org-switch/use-org.jsx +14 -2
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
import { default as PropTypes } from 'prop-types';
|
|
2
|
-
declare function
|
|
2
|
+
declare function OrgMutateDialog({ mode, org, onSuccess, onCancel, locale, teamDid: teamDidProp, prefix, headers, }: {
|
|
3
|
+
mode?: string | undefined;
|
|
4
|
+
org?: null | undefined;
|
|
3
5
|
onSuccess?: ((...args: any[]) => void) | undefined;
|
|
4
6
|
onCancel?: ((...args: any[]) => void) | undefined;
|
|
5
7
|
locale?: string | undefined;
|
|
8
|
+
teamDid?: string | undefined;
|
|
9
|
+
prefix?: string | undefined;
|
|
10
|
+
headers?: ((...args: any[]) => void) | undefined;
|
|
6
11
|
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
declare namespace
|
|
8
|
-
namespace propTypes {
|
|
12
|
+
declare namespace OrgMutateDialog {
|
|
13
|
+
export namespace propTypes {
|
|
14
|
+
let mode: PropTypes.Requireable<string>;
|
|
15
|
+
let org: PropTypes.Requireable<PropTypes.InferProps<{
|
|
16
|
+
id: PropTypes.Requireable<string>;
|
|
17
|
+
name: PropTypes.Requireable<string>;
|
|
18
|
+
description: PropTypes.Requireable<string>;
|
|
19
|
+
avatar: PropTypes.Requireable<string>;
|
|
20
|
+
}>>;
|
|
9
21
|
let onSuccess: PropTypes.Requireable<(...args: any[]) => any>;
|
|
10
22
|
let onCancel: PropTypes.Requireable<(...args: any[]) => any>;
|
|
11
23
|
let locale: PropTypes.Requireable<string>;
|
|
24
|
+
let teamDid: PropTypes.Requireable<string>;
|
|
25
|
+
let prefix: PropTypes.Requireable<string>;
|
|
26
|
+
let headers: PropTypes.Requireable<(...args: any[]) => any>;
|
|
12
27
|
}
|
|
28
|
+
export { MODE_CREATE };
|
|
29
|
+
export { MODE_EDIT };
|
|
13
30
|
}
|
|
14
|
-
export default
|
|
31
|
+
export default OrgMutateDialog;
|
|
32
|
+
export { OrgMutateDialog as CreateOrgDialog };
|
|
33
|
+
declare const MODE_CREATE: "create";
|
|
34
|
+
declare const MODE_EDIT: "edit";
|
|
@@ -1,120 +1,181 @@
|
|
|
1
|
-
import { jsxs as m, jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import
|
|
4
|
-
import { useMemoizedFn as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { translate as
|
|
11
|
-
import { formatAxiosError as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { jsxs as m, jsx as o, Fragment as P } from "react/jsx-runtime";
|
|
2
|
+
import { useState as D, useEffect as q } from "react";
|
|
3
|
+
import a from "prop-types";
|
|
4
|
+
import { useMemoizedFn as d, useReactive as U } from "ahooks";
|
|
5
|
+
import u from "lodash/noop";
|
|
6
|
+
import G from "@arcblock/ux/lib/Dialog";
|
|
7
|
+
import { DialogContentText as H, Box as J, Typography as p, TextField as w, Alert as K, CircularProgress as N } from "@mui/material";
|
|
8
|
+
import Q from "@arcblock/ux/lib/Toast";
|
|
9
|
+
import O from "@arcblock/ux/lib/Button";
|
|
10
|
+
import { translate as V } from "@arcblock/ux/lib/Locale/util";
|
|
11
|
+
import { formatAxiosError as X } from "../../UserCenter/libs/utils.js";
|
|
12
|
+
import Y from "./use-org.js";
|
|
13
|
+
import Z from "./locales.js";
|
|
14
|
+
import $ from "./avatar-uploader.js";
|
|
15
|
+
const f = "create", g = "edit";
|
|
16
|
+
function v({
|
|
17
|
+
mode: _ = f,
|
|
18
|
+
org: i = null,
|
|
19
|
+
onSuccess: b = u,
|
|
20
|
+
onCancel: h = u,
|
|
21
|
+
locale: M = "en",
|
|
22
|
+
teamDid: A = "",
|
|
23
|
+
prefix: F = "/.well-known/service",
|
|
24
|
+
headers: B = u
|
|
25
|
+
}) {
|
|
26
|
+
const s = _ === g, [c, y] = D(!1), [E, n] = D(""), { createOrg: k, updateOrg: z } = Y(), I = A || (typeof window < "u" ? window.blocklet?.did : ""), e = d((r, l = {}) => V(Z, r, M, "en", l)), t = U({
|
|
16
27
|
name: "",
|
|
17
|
-
description: ""
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
description: "",
|
|
29
|
+
avatar: ""
|
|
30
|
+
});
|
|
31
|
+
q(() => {
|
|
32
|
+
s && i && (t.name = i.name || "", t.description = i.description || "", t.avatar = i.avatar || "");
|
|
33
|
+
}, [s, i]);
|
|
34
|
+
const L = d((r) => {
|
|
35
|
+
n(""), t.avatar = r;
|
|
36
|
+
}), R = d(() => {
|
|
37
|
+
const r = t.name.trim();
|
|
38
|
+
return r ? r.length > 25 ? (n(e("nameTooLong", { length: 25 })), !1) : t.description.trim().length > 255 ? (n(e("descriptionTooLong", { length: 255 })), !1) : t.avatar ? !0 : (n(e("avatarEmpty")), !1) : (n(e("nameEmpty")), !1);
|
|
39
|
+
}), S = async () => {
|
|
40
|
+
if (!R())
|
|
22
41
|
return;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
o(t("nameTooLong", { length: 25 }));
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const a = n.description.trim();
|
|
29
|
-
if (a.length > 255) {
|
|
30
|
-
o(t("descriptionTooLong", { length: 25 }));
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
o(""), c(!0);
|
|
42
|
+
n(""), y(!0);
|
|
43
|
+
const r = t.name.trim(), l = t.description.trim(), T = t.avatar;
|
|
34
44
|
try {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
s && i?.id ? await z(i.id, {
|
|
46
|
+
name: r,
|
|
47
|
+
description: l,
|
|
48
|
+
avatar: T
|
|
49
|
+
}) : await k({
|
|
50
|
+
name: r,
|
|
51
|
+
description: l,
|
|
52
|
+
avatar: T
|
|
53
|
+
}), b();
|
|
54
|
+
} catch (x) {
|
|
55
|
+
console.error(x);
|
|
56
|
+
const C = X(x);
|
|
57
|
+
n(C), Q.error(C);
|
|
40
58
|
} finally {
|
|
41
|
-
|
|
59
|
+
y(!1);
|
|
42
60
|
}
|
|
43
|
-
},
|
|
44
|
-
/* @__PURE__ */ r(h, { component: "div", style: { marginTop: 16 }, children: /* @__PURE__ */ r(
|
|
45
|
-
y,
|
|
46
|
-
{
|
|
47
|
-
label: t("mutate.name"),
|
|
48
|
-
autoComplete: "off",
|
|
49
|
-
variant: "outlined",
|
|
50
|
-
name: "name",
|
|
51
|
-
"data-cy": "mutate-org-input-name",
|
|
52
|
-
fullWidth: !0,
|
|
53
|
-
autoFocus: !0,
|
|
54
|
-
value: n.name,
|
|
55
|
-
onChange: (e) => {
|
|
56
|
-
o(""), n.name = e.target.value;
|
|
57
|
-
},
|
|
58
|
-
disabled: i
|
|
59
|
-
}
|
|
60
|
-
) }),
|
|
61
|
-
/* @__PURE__ */ r(h, { component: "div", style: { marginTop: 16, marginBottom: 16 }, children: /* @__PURE__ */ r(
|
|
62
|
-
y,
|
|
63
|
-
{
|
|
64
|
-
label: t("mutate.description"),
|
|
65
|
-
autoComplete: "off",
|
|
66
|
-
variant: "outlined",
|
|
67
|
-
name: "description",
|
|
68
|
-
"data-cy": "mutate-org-input-description",
|
|
69
|
-
fullWidth: !0,
|
|
70
|
-
value: n.description,
|
|
71
|
-
onChange: (e) => {
|
|
72
|
-
o(""), n.description = e.target.value;
|
|
73
|
-
},
|
|
74
|
-
disabled: i,
|
|
75
|
-
multiline: !0,
|
|
76
|
-
rows: 3
|
|
77
|
-
}
|
|
78
|
-
) })
|
|
79
|
-
] });
|
|
61
|
+
}, W = s ? e("mutate.title", { mode: e("edit") }) : e("mutate.title", { mode: e("create") }), j = e(s ? "save" : "create");
|
|
80
62
|
return /* @__PURE__ */ m(
|
|
81
|
-
|
|
63
|
+
G,
|
|
82
64
|
{
|
|
83
|
-
title:
|
|
65
|
+
title: W,
|
|
84
66
|
fullWidth: !0,
|
|
85
67
|
open: !0,
|
|
86
|
-
onClose:
|
|
68
|
+
onClose: h,
|
|
87
69
|
showCloseButton: !1,
|
|
88
|
-
actions: /* @__PURE__ */ m(
|
|
89
|
-
/* @__PURE__ */
|
|
70
|
+
actions: /* @__PURE__ */ m(P, { children: [
|
|
71
|
+
/* @__PURE__ */ o(O, { onClick: h, color: "inherit", children: e("cancel") }),
|
|
90
72
|
/* @__PURE__ */ m(
|
|
91
|
-
|
|
73
|
+
O,
|
|
92
74
|
{
|
|
93
75
|
"data-cy": "mutate-org-confirm",
|
|
94
|
-
onClick:
|
|
76
|
+
onClick: S,
|
|
95
77
|
color: "primary",
|
|
96
|
-
disabled:
|
|
78
|
+
disabled: c,
|
|
97
79
|
variant: "contained",
|
|
98
80
|
autoFocus: !0,
|
|
99
81
|
children: [
|
|
100
|
-
|
|
101
|
-
|
|
82
|
+
c && /* @__PURE__ */ o(N, { size: 16, sx: { mr: 1 } }),
|
|
83
|
+
j
|
|
102
84
|
]
|
|
103
85
|
}
|
|
104
86
|
)
|
|
105
87
|
] }),
|
|
106
88
|
children: [
|
|
107
|
-
/* @__PURE__ */
|
|
108
|
-
|
|
89
|
+
/* @__PURE__ */ m(H, { component: "div", children: [
|
|
90
|
+
/* @__PURE__ */ m(
|
|
91
|
+
J,
|
|
92
|
+
{
|
|
93
|
+
sx: {
|
|
94
|
+
display: "flex",
|
|
95
|
+
flexDirection: "column",
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
py: 2
|
|
98
|
+
},
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ o(
|
|
101
|
+
$,
|
|
102
|
+
{
|
|
103
|
+
org: s ? i : { name: t.name },
|
|
104
|
+
size: 90,
|
|
105
|
+
teamDid: I,
|
|
106
|
+
prefix: F,
|
|
107
|
+
headers: B,
|
|
108
|
+
onChange: L,
|
|
109
|
+
value: t.avatar,
|
|
110
|
+
editable: !0
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
/* @__PURE__ */ o(p, { variant: "caption", color: "text.secondary", sx: { mt: 1 }, children: e("avatar") })
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
/* @__PURE__ */ o(p, { component: "div", style: { marginTop: 16 }, children: /* @__PURE__ */ o(
|
|
118
|
+
w,
|
|
119
|
+
{
|
|
120
|
+
label: e("mutate.name"),
|
|
121
|
+
autoComplete: "off",
|
|
122
|
+
variant: "outlined",
|
|
123
|
+
name: "name",
|
|
124
|
+
"data-cy": "mutate-org-input-name",
|
|
125
|
+
fullWidth: !0,
|
|
126
|
+
autoFocus: !0,
|
|
127
|
+
value: t.name,
|
|
128
|
+
onChange: (r) => {
|
|
129
|
+
n(""), t.name = r.target.value;
|
|
130
|
+
},
|
|
131
|
+
disabled: c,
|
|
132
|
+
required: !0
|
|
133
|
+
}
|
|
134
|
+
) }),
|
|
135
|
+
/* @__PURE__ */ o(p, { component: "div", style: { marginTop: 16, marginBottom: 16 }, children: /* @__PURE__ */ o(
|
|
136
|
+
w,
|
|
137
|
+
{
|
|
138
|
+
label: e("mutate.description"),
|
|
139
|
+
autoComplete: "off",
|
|
140
|
+
variant: "outlined",
|
|
141
|
+
name: "description",
|
|
142
|
+
"data-cy": "mutate-org-input-description",
|
|
143
|
+
fullWidth: !0,
|
|
144
|
+
value: t.description,
|
|
145
|
+
onChange: (r) => {
|
|
146
|
+
n(""), t.description = r.target.value;
|
|
147
|
+
},
|
|
148
|
+
disabled: c,
|
|
149
|
+
multiline: !0,
|
|
150
|
+
rows: 3
|
|
151
|
+
}
|
|
152
|
+
) })
|
|
153
|
+
] }),
|
|
154
|
+
!!E && /* @__PURE__ */ o(K, { severity: "error", style: { width: "100%", margin: 0 }, children: E })
|
|
109
155
|
]
|
|
110
156
|
}
|
|
111
157
|
);
|
|
112
158
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
159
|
+
v.propTypes = {
|
|
160
|
+
/** 操作模式:'create' 创建 | 'edit' 编辑 */
|
|
161
|
+
mode: a.oneOf([f, g]),
|
|
162
|
+
/** 编辑模式下的组织数据 */
|
|
163
|
+
org: a.shape({
|
|
164
|
+
id: a.string,
|
|
165
|
+
name: a.string,
|
|
166
|
+
description: a.string,
|
|
167
|
+
avatar: a.string
|
|
168
|
+
}),
|
|
169
|
+
onSuccess: a.func,
|
|
170
|
+
onCancel: a.func,
|
|
171
|
+
locale: a.string,
|
|
172
|
+
teamDid: a.string,
|
|
173
|
+
prefix: a.string,
|
|
174
|
+
headers: a.func
|
|
117
175
|
};
|
|
176
|
+
v.MODE_CREATE = f;
|
|
177
|
+
v.MODE_EDIT = g;
|
|
118
178
|
export {
|
|
119
|
-
|
|
179
|
+
v as CreateOrgDialog,
|
|
180
|
+
v as default
|
|
120
181
|
};
|
|
@@ -36,9 +36,9 @@ function ye({ session: a, locale: h = "en" }) {
|
|
|
36
36
|
console.error("Failed to fetch organizations list", e);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
), { list: p = [], total: q = 0 } = K || {},
|
|
39
|
+
), { list: p = [], total: q = 0 } = K || {}, M = p.length < q, U = k((e) => {
|
|
40
40
|
const o = e.target, { scrollTop: c, scrollHeight: y, clientHeight: b } = o;
|
|
41
|
-
y - c - b < 50 && !z &&
|
|
41
|
+
y - c - b < 50 && !z && M && V();
|
|
42
42
|
}), x = !!S;
|
|
43
43
|
ee(() => {
|
|
44
44
|
x && O();
|
|
@@ -56,7 +56,7 @@ function ye({ session: a, locale: h = "en" }) {
|
|
|
56
56
|
), f();
|
|
57
57
|
}, Q = () => {
|
|
58
58
|
u(!0);
|
|
59
|
-
},
|
|
59
|
+
}, T = () => {
|
|
60
60
|
const e = le(ce(ne, "user/orgs"), { locale: h });
|
|
61
61
|
window.location.href = e, f();
|
|
62
62
|
}, X = (e) => /* @__PURE__ */ i(
|
|
@@ -214,7 +214,7 @@ function ye({ session: a, locale: h = "en" }) {
|
|
|
214
214
|
const c = o === p.length - 1;
|
|
215
215
|
return /* @__PURE__ */ i(r, { children: [
|
|
216
216
|
X(e),
|
|
217
|
-
c &&
|
|
217
|
+
c && M && /* @__PURE__ */ t(
|
|
218
218
|
r,
|
|
219
219
|
{
|
|
220
220
|
sx: {
|
|
@@ -267,7 +267,7 @@ function ye({ session: a, locale: h = "en" }) {
|
|
|
267
267
|
/* @__PURE__ */ t(r, { sx: { p: 1.5 }, children: /* @__PURE__ */ t(
|
|
268
268
|
P,
|
|
269
269
|
{
|
|
270
|
-
onClick:
|
|
270
|
+
onClick: T,
|
|
271
271
|
variant: "text",
|
|
272
272
|
component: "a",
|
|
273
273
|
size: "small",
|
|
@@ -289,7 +289,7 @@ function ye({ session: a, locale: h = "en" }) {
|
|
|
289
289
|
]
|
|
290
290
|
}
|
|
291
291
|
),
|
|
292
|
-
j && /* @__PURE__ */ t(xe, { onSuccess:
|
|
292
|
+
j && /* @__PURE__ */ t(xe, { onSuccess: T, onCancel: () => u(!1), locale: h })
|
|
293
293
|
] });
|
|
294
294
|
}
|
|
295
295
|
ye.propTypes = {
|
|
@@ -10,12 +10,18 @@ declare namespace translations {
|
|
|
10
10
|
let nameEmpty: string;
|
|
11
11
|
let nameTooLong: string;
|
|
12
12
|
let descriptionTooLong: string;
|
|
13
|
+
let avatarEmpty: string;
|
|
13
14
|
let cancel: string;
|
|
14
15
|
let create: string;
|
|
16
|
+
let upload: string;
|
|
17
|
+
let avatar: string;
|
|
15
18
|
namespace mutate {
|
|
16
19
|
let title: string;
|
|
17
20
|
let name: string;
|
|
18
21
|
let description: string;
|
|
22
|
+
let avatarRequired: string;
|
|
23
|
+
let uploadAvatarTitle: string;
|
|
24
|
+
let uploadAvatarTip: string;
|
|
19
25
|
}
|
|
20
26
|
}
|
|
21
27
|
namespace zh {
|
|
@@ -37,10 +43,16 @@ declare namespace translations {
|
|
|
37
43
|
export { nameTooLong_1 as nameTooLong };
|
|
38
44
|
let descriptionTooLong_1: string;
|
|
39
45
|
export { descriptionTooLong_1 as descriptionTooLong };
|
|
46
|
+
let avatarEmpty_1: string;
|
|
47
|
+
export { avatarEmpty_1 as avatarEmpty };
|
|
48
|
+
let upload_1: string;
|
|
49
|
+
export { upload_1 as upload };
|
|
40
50
|
let cancel_1: string;
|
|
41
51
|
export { cancel_1 as cancel };
|
|
42
52
|
let create_1: string;
|
|
43
53
|
export { create_1 as create };
|
|
54
|
+
let avatar_1: string;
|
|
55
|
+
export { avatar_1 as avatar };
|
|
44
56
|
export namespace mutate_1 {
|
|
45
57
|
let title_1: string;
|
|
46
58
|
export { title_1 as title };
|
|
@@ -48,6 +60,12 @@ declare namespace translations {
|
|
|
48
60
|
export { name_1 as name };
|
|
49
61
|
let description_1: string;
|
|
50
62
|
export { description_1 as description };
|
|
63
|
+
let avatarRequired_1: string;
|
|
64
|
+
export { avatarRequired_1 as avatarRequired };
|
|
65
|
+
let uploadAvatarTitle_1: string;
|
|
66
|
+
export { uploadAvatarTitle_1 as uploadAvatarTitle };
|
|
67
|
+
let uploadAvatarTip_1: string;
|
|
68
|
+
export { uploadAvatarTip_1 as uploadAvatarTip };
|
|
51
69
|
}
|
|
52
70
|
export { mutate_1 as mutate };
|
|
53
71
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a = {
|
|
2
2
|
en: {
|
|
3
3
|
search: "Search",
|
|
4
4
|
orgs: "Organizations",
|
|
@@ -9,12 +9,18 @@ const e = {
|
|
|
9
9
|
nameEmpty: "Name cannot be empty",
|
|
10
10
|
nameTooLong: "Name must be less than {length} characters",
|
|
11
11
|
descriptionTooLong: "Description must be less than {length} characters",
|
|
12
|
+
avatarEmpty: "Avatar cannot be empty",
|
|
12
13
|
cancel: "Cancel",
|
|
13
14
|
create: "Create",
|
|
15
|
+
upload: "Upload",
|
|
16
|
+
avatar: "Avatar",
|
|
14
17
|
mutate: {
|
|
15
18
|
title: "{mode} Organization",
|
|
16
19
|
name: "Name",
|
|
17
|
-
description: "Description"
|
|
20
|
+
description: "Description",
|
|
21
|
+
avatarRequired: "Avatar is required",
|
|
22
|
+
uploadAvatarTitle: "Upload Avatar",
|
|
23
|
+
uploadAvatarTip: "Click to upload an avatar for your organization"
|
|
18
24
|
}
|
|
19
25
|
},
|
|
20
26
|
zh: {
|
|
@@ -27,15 +33,21 @@ const e = {
|
|
|
27
33
|
nameEmpty: "名称不能为空",
|
|
28
34
|
nameTooLong: "名称不能超过{length}个字符",
|
|
29
35
|
descriptionTooLong: "描述不能超过{length}个字符",
|
|
36
|
+
avatarEmpty: "头像不能为空",
|
|
37
|
+
upload: "上传",
|
|
30
38
|
cancel: "取消",
|
|
31
39
|
create: "创建",
|
|
40
|
+
avatar: "头像",
|
|
32
41
|
mutate: {
|
|
33
42
|
title: "{mode}组织",
|
|
34
43
|
name: "组织名称",
|
|
35
|
-
description: "组织描述"
|
|
44
|
+
description: "组织描述",
|
|
45
|
+
avatarRequired: "头像为必填项",
|
|
46
|
+
uploadAvatarTitle: "上传头像",
|
|
47
|
+
uploadAvatarTip: "点击上传组织头像"
|
|
36
48
|
}
|
|
37
49
|
}
|
|
38
50
|
};
|
|
39
51
|
export {
|
|
40
|
-
|
|
52
|
+
a as default
|
|
41
53
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export default function useOrg(session: any): {
|
|
2
2
|
getOrgs: (this: any, args_0?: any) => Promise<any>;
|
|
3
3
|
createOrg: (this: any, args_0?: any) => Promise<any>;
|
|
4
|
+
updateOrg: (this: any, orgId?: any, args_1?: any) => Promise<any>;
|
|
4
5
|
getCurrentOrg: (this: any, roleName?: any) => Promise<any>;
|
|
5
6
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { useMemoizedFn as
|
|
2
|
-
import
|
|
3
|
-
import { getBlockletSDK as
|
|
4
|
-
import { formatAxiosError as
|
|
5
|
-
function
|
|
6
|
-
const
|
|
1
|
+
import { useMemoizedFn as s } from "ahooks";
|
|
2
|
+
import c from "@arcblock/ux/lib/Toast";
|
|
3
|
+
import { getBlockletSDK as y } from "@blocklet/js-sdk";
|
|
4
|
+
import { formatAxiosError as u } from "../../UserCenter/libs/utils.js";
|
|
5
|
+
function x(g) {
|
|
6
|
+
const n = y(), l = s(async ({ search: t, page: r = 1, pageSize: o = 20 }) => {
|
|
7
7
|
try {
|
|
8
|
-
return await
|
|
9
|
-
} catch (
|
|
10
|
-
return console.error(
|
|
8
|
+
return await n.user.getOrgs({ search: t, page: r, pageSize: o });
|
|
9
|
+
} catch (e) {
|
|
10
|
+
return console.error(e), {
|
|
11
11
|
orgs: [],
|
|
12
12
|
paging: {
|
|
13
13
|
page: r,
|
|
@@ -16,32 +16,39 @@ function w(c) {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
}),
|
|
19
|
+
}), i = s(async ({ name: t, description: r, avatar: o }) => {
|
|
20
20
|
try {
|
|
21
|
-
return (await
|
|
22
|
-
} catch (
|
|
23
|
-
return console.error(
|
|
21
|
+
return (await n.user.createOrg({ name: t, description: r, avatar: o })).data;
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return console.error(e), c.error(u(e)), null;
|
|
24
24
|
}
|
|
25
|
-
}),
|
|
25
|
+
}), p = s(async (t, { name: r, description: o, avatar: e }) => {
|
|
26
26
|
try {
|
|
27
|
-
return await
|
|
27
|
+
return (await n.user.updateOrg(t, { name: r, description: o, avatar: e })).data;
|
|
28
|
+
} catch (a) {
|
|
29
|
+
return console.error(a), c.error(u(a)), null;
|
|
30
|
+
}
|
|
31
|
+
}), d = s(async (t) => {
|
|
32
|
+
try {
|
|
33
|
+
return await n.user.getOrg(t);
|
|
28
34
|
} catch (r) {
|
|
29
|
-
return
|
|
35
|
+
return g.logout(), console.error(r), null;
|
|
30
36
|
}
|
|
31
|
-
}),
|
|
37
|
+
}), m = s(async (t) => {
|
|
32
38
|
try {
|
|
33
|
-
const r = await
|
|
34
|
-
return r.orgId ? await
|
|
39
|
+
const r = await n.user.getRole(t);
|
|
40
|
+
return r.orgId ? await d(r.orgId) : null;
|
|
35
41
|
} catch (r) {
|
|
36
42
|
return console.error(r), null;
|
|
37
43
|
}
|
|
38
44
|
});
|
|
39
45
|
return {
|
|
40
|
-
getOrgs:
|
|
41
|
-
createOrg:
|
|
42
|
-
|
|
46
|
+
getOrgs: l,
|
|
47
|
+
createOrg: i,
|
|
48
|
+
updateOrg: p,
|
|
49
|
+
getCurrentOrg: m
|
|
43
50
|
};
|
|
44
51
|
}
|
|
45
52
|
export {
|
|
46
|
-
|
|
53
|
+
x as default
|
|
47
54
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.8",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"component",
|
|
9
9
|
"blocklet"
|
|
10
10
|
],
|
|
11
|
+
"sideEffects": false,
|
|
11
12
|
"author": "wangshijun<wangshijun2010@gmail.com>",
|
|
12
13
|
"homepage": "https://www.arcblock.io/docs/blocklet-ui-react",
|
|
13
14
|
"license": "Apache-2.0",
|
|
@@ -35,11 +36,12 @@
|
|
|
35
36
|
"dependencies": {
|
|
36
37
|
"@abtnode/constant": "^1.17.7",
|
|
37
38
|
"@abtnode/util": "^1.17.7",
|
|
38
|
-
"@arcblock/bridge": "3.4.
|
|
39
|
-
"@arcblock/icons": "3.4.
|
|
40
|
-
"@arcblock/react-hooks": "3.4.
|
|
41
|
-
"@arcblock/ws": "^1.28.
|
|
42
|
-
"@blocklet/did-space-react": "^1.2.
|
|
39
|
+
"@arcblock/bridge": "3.4.8",
|
|
40
|
+
"@arcblock/icons": "3.4.8",
|
|
41
|
+
"@arcblock/react-hooks": "3.4.8",
|
|
42
|
+
"@arcblock/ws": "^1.28.5",
|
|
43
|
+
"@blocklet/did-space-react": "^1.2.15",
|
|
44
|
+
"@blocklet/uploader": "^0.3.19",
|
|
43
45
|
"@iconify-icons/logos": "^1.2.36",
|
|
44
46
|
"@iconify-icons/material-symbols": "^1.2.58",
|
|
45
47
|
"@iconify-icons/tabler": "^1.2.95",
|
|
@@ -82,7 +84,7 @@
|
|
|
82
84
|
"access": "public"
|
|
83
85
|
},
|
|
84
86
|
"devDependencies": {
|
|
85
|
-
"@arcblock/did-connect-react": "3.4.
|
|
87
|
+
"@arcblock/did-connect-react": "3.4.8",
|
|
86
88
|
"@babel/preset-env": "^7.28.0",
|
|
87
89
|
"@babel/preset-react": "^7.27.1",
|
|
88
90
|
"@babel/preset-typescript": "^7.27.1",
|
|
@@ -96,5 +98,5 @@
|
|
|
96
98
|
"typescript": "~5.5.4",
|
|
97
99
|
"unbuild": "^2.0.0"
|
|
98
100
|
},
|
|
99
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "6bbdc63e6e0b7ddfd5e37f2ac6bb44ee49da7139"
|
|
100
102
|
}
|
|
@@ -497,9 +497,11 @@ export default function UserMetadataComponent({
|
|
|
497
497
|
<PhoneInput
|
|
498
498
|
variant="outlined"
|
|
499
499
|
className="editable-field"
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
500
|
+
slotProps={{
|
|
501
|
+
input: {
|
|
502
|
+
sx: { backgroundColor: 'transparent' },
|
|
503
|
+
placeholder: 'Phone',
|
|
504
|
+
},
|
|
503
505
|
}}
|
|
504
506
|
value={phoneValue}
|
|
505
507
|
error={!!validateMsg.phone}
|
|
@@ -6,7 +6,7 @@ import { useMemoizedFn } from 'ahooks';
|
|
|
6
6
|
import { translate } from '@arcblock/ux/lib/Locale/util';
|
|
7
7
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
8
8
|
import noop from 'lodash/noop';
|
|
9
|
-
import { useEffect, useState } from 'react';
|
|
9
|
+
import { lazy, useEffect, useState } from 'react';
|
|
10
10
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
11
11
|
import type { AxiosError } from 'axios';
|
|
12
12
|
import { parseURL, joinURL } from 'ufo';
|
|
@@ -21,11 +21,13 @@ import type { User, UserAddress, UserMetadata } from '../../../@types';
|
|
|
21
21
|
import { formatAxiosError } from '../../libs/utils';
|
|
22
22
|
import { currentTimezone, getStatusDuration, isValidUrl, isDuplicateUrl } from './utils';
|
|
23
23
|
import SwitchRole from './switch-role';
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
import UserStatus from './user-status';
|
|
26
26
|
import UserInfo from './user-info';
|
|
27
27
|
import SocialActions from './social-actions';
|
|
28
28
|
|
|
29
|
+
const UserMetadataComponent = lazy(() => import('./metadata'));
|
|
30
|
+
|
|
29
31
|
export default function UserBasicInfo({
|
|
30
32
|
user,
|
|
31
33
|
isMyself = true,
|