@blocklet/ui-react 2.9.67 → 2.9.69

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.
Files changed (54) hide show
  1. package/es/@types/index.d.ts +38 -1
  2. package/es/@types/shims.d.ts +6 -0
  3. package/es/Dashboard/index.js +0 -1
  4. package/es/UserCenter/components/settings.js +7 -1
  5. package/es/UserCenter/components/third-party-login/index.d.ts +5 -0
  6. package/es/UserCenter/components/third-party-login/index.js +111 -0
  7. package/es/UserCenter/components/third-party-login/third-party-item.d.ts +13 -0
  8. package/es/UserCenter/components/third-party-login/third-party-item.js +227 -0
  9. package/es/UserCenter/components/user-center.js +22 -17
  10. package/es/UserCenter/components/user-info/index.d.ts +3 -0
  11. package/es/UserCenter/components/user-info/index.js +3 -0
  12. package/es/UserCenter/components/{user-basic-info.d.ts → user-info/user-basic-info.d.ts} +1 -1
  13. package/es/UserCenter/components/{user-basic-info.js → user-info/user-basic-info.js} +1 -1
  14. package/es/UserCenter/components/{user-info.d.ts → user-info/user-info.d.ts} +1 -1
  15. package/es/UserCenter/components/{user-info.js → user-info/user-info.js} +3 -6
  16. package/es/UserCenter/libs/locales.d.ts +20 -0
  17. package/es/UserCenter/libs/locales.js +20 -0
  18. package/es/UserSessions/components/user-sessions.js +1 -4
  19. package/lib/@types/index.d.ts +38 -1
  20. package/lib/@types/shims.d.ts +6 -0
  21. package/lib/Dashboard/index.js +1 -3
  22. package/lib/UserCenter/components/settings.js +8 -1
  23. package/lib/UserCenter/components/third-party-login/index.d.ts +5 -0
  24. package/lib/UserCenter/components/third-party-login/index.js +123 -0
  25. package/lib/UserCenter/components/third-party-login/third-party-item.d.ts +13 -0
  26. package/lib/UserCenter/components/third-party-login/third-party-item.js +235 -0
  27. package/lib/UserCenter/components/user-center.js +23 -16
  28. package/lib/UserCenter/components/user-info/index.d.ts +3 -0
  29. package/lib/UserCenter/components/user-info/index.js +27 -0
  30. package/lib/UserCenter/components/{user-basic-info.d.ts → user-info/user-basic-info.d.ts} +1 -1
  31. package/lib/UserCenter/components/{user-basic-info.js → user-info/user-basic-info.js} +1 -1
  32. package/lib/UserCenter/components/{user-info.d.ts → user-info/user-info.d.ts} +1 -1
  33. package/lib/UserCenter/components/{user-info.js → user-info/user-info.js} +3 -6
  34. package/lib/UserCenter/libs/locales.d.ts +20 -0
  35. package/lib/UserCenter/libs/locales.js +20 -0
  36. package/lib/UserSessions/components/user-sessions.js +1 -4
  37. package/package.json +10 -9
  38. package/src/@types/index.ts +42 -1
  39. package/src/@types/shims.d.ts +6 -0
  40. package/src/Dashboard/index.jsx +2 -1
  41. package/src/UserCenter/components/settings.tsx +7 -1
  42. package/src/UserCenter/components/third-party-login/index.tsx +133 -0
  43. package/src/UserCenter/components/third-party-login/third-party-item.tsx +239 -0
  44. package/src/UserCenter/components/user-center.tsx +24 -17
  45. package/src/UserCenter/components/user-info/index.tsx +3 -0
  46. package/src/UserCenter/components/{user-basic-info.tsx → user-info/user-basic-info.tsx} +2 -2
  47. package/src/UserCenter/components/{user-info.tsx → user-info/user-info.tsx} +4 -7
  48. package/src/UserCenter/libs/locales.ts +22 -0
  49. package/src/UserSessions/components/user-sessions.tsx +0 -3
  50. /package/es/UserCenter/components/{user-info-item.d.ts → user-info/user-info-item.d.ts} +0 -0
  51. /package/es/UserCenter/components/{user-info-item.js → user-info/user-info-item.js} +0 -0
  52. /package/lib/UserCenter/components/{user-info-item.d.ts → user-info/user-info-item.d.ts} +0 -0
  53. /package/lib/UserCenter/components/{user-info-item.js → user-info/user-info-item.js} +0 -0
  54. /package/src/UserCenter/components/{user-info-item.tsx → user-info/user-info-item.tsx} +0 -0
@@ -1,19 +1,55 @@
1
1
  import type { Axios } from 'axios';
2
2
  import type { UserPublicInfo } from '@blocklet/js-sdk';
3
+ import { OAUTH_PROVIDER } from '@arcblock/ux/lib/Util/constant';
3
4
  export type SessionContext = {
4
5
  session: Session;
5
6
  api: Axios;
6
7
  };
8
+ export type OAuthAccount = {
9
+ provider: keyof typeof OAUTH_PROVIDER;
10
+ id: string;
11
+ did: string;
12
+ pk: string;
13
+ lastLoginAt: string;
14
+ firstLoginAt: string;
15
+ order?: number;
16
+ userInfo?: {
17
+ email: string;
18
+ emailVerified: boolean;
19
+ name: string;
20
+ picture: string;
21
+ sub: string;
22
+ extraData: Object;
23
+ };
24
+ };
25
+ export type WalletAccount = {
26
+ provider: 'wallet';
27
+ did: string;
28
+ pk: string;
29
+ lastLoginAt: string;
30
+ firstLoginAt: string;
31
+ };
32
+ export type NFTAccount = {
33
+ provider: 'nft';
34
+ did: string;
35
+ pk: string;
36
+ owner: string;
37
+ lastLoginAt: string;
38
+ firstLoginAt: string;
39
+ };
40
+ export type ConnectedAccount = OAuthAccount | WalletAccount | NFTAccount;
7
41
  export type User = UserPublicInfo & {
8
42
  role: string;
9
43
  email?: string;
10
44
  phone?: string;
11
45
  sourceProvider?: string;
46
+ sourceAppPid?: string;
12
47
  lastLoginAt?: string;
13
48
  lastLoginIp?: string;
14
49
  createdAt?: string;
15
50
  passports?: any[];
16
51
  didSpace?: Record<string, any>;
52
+ connectedAccounts?: any[];
17
53
  };
18
54
  export type UserCenterTab = {
19
55
  value: string;
@@ -25,7 +61,7 @@ export type UserCenterTab = {
25
61
  export type Session = {
26
62
  loading: boolean;
27
63
  initialized: boolean;
28
- user: User;
64
+ user?: User;
29
65
  login: any;
30
66
  logout: any;
31
67
  switch: any;
@@ -33,6 +69,7 @@ export type Session = {
33
69
  switchProfile: any;
34
70
  switchPassport: any;
35
71
  refresh: Function;
72
+ useOAuth: Function;
36
73
  };
37
74
  export type WebhookType = 'slack' | 'api';
38
75
  export type WebhookItemData = {
@@ -1,5 +1,11 @@
1
1
  declare module '@arcblock/ux/*';
2
+ declare module '@arcblock/ux/lib/DID';
3
+ declare module '@arcblock/ux/lib/Tabs';
4
+ declare module '@arcblock/ux/lib/Switch';
5
+ declare module '@arcblock/ux/lib/ErrorBoundary';
6
+
2
7
  declare module '@arcblock/did-connect/*';
8
+ declare module '@arcblock/did-connect/lib/Session';
3
9
 
4
10
  declare module 'is-url';
5
11
  declare module 'url-join';
@@ -58,7 +58,6 @@ function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessi
58
58
  if (invalidPathFallback) {
59
59
  invalidPathFallback();
60
60
  } else {
61
- window.location.href = flattened[0]?.url || publicPath;
62
61
  }
63
62
  }
64
63
  }, [invalidPathFallback, flattened, matchedIndex]);
@@ -10,6 +10,7 @@ import Notification from "./notification.js";
10
10
  import Privacy from "./privacy.js";
11
11
  import DidSpace from "./storage/index.js";
12
12
  import { UserSessions } from "../../UserSessions/index.js";
13
+ import ThirdPartyLogin from "./third-party-login/index.js";
13
14
  export default function Settings({
14
15
  user,
15
16
  settings,
@@ -37,6 +38,11 @@ export default function Settings({
37
38
  value: "notification",
38
39
  content: /* @__PURE__ */ jsx(Notification, { user })
39
40
  },
41
+ {
42
+ label: t("thirdPartyLogin.title"),
43
+ value: "thirdPartyLogin",
44
+ content: /* @__PURE__ */ jsx(ThirdPartyLogin, { user })
45
+ },
40
46
  {
41
47
  label: t("privacyManagement"),
42
48
  value: "privacy",
@@ -59,7 +65,7 @@ export default function Settings({
59
65
  });
60
66
  const currentTab = useCreation(() => {
61
67
  return tabs.find((x) => x.value === currentState.tab);
62
- }, [currentState.tab]);
68
+ }, [currentState.tab, tabs]);
63
69
  const handleChangeTab = useMemoizedFn((value) => {
64
70
  currentState.tab = value;
65
71
  });
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import type { User } from '../../../@types';
3
+ export default function ThirdPartyLogin({ user }: {
4
+ user: User;
5
+ }): import("react").JSX.Element;
@@ -0,0 +1,111 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useContext, useState } from "react";
3
+ import { List } from "@mui/material";
4
+ import { useAsyncEffect, useCreation } from "ahooks";
5
+ import { getConnectedAccounts, getSourceProvider } from "@arcblock/ux/lib/SessionUser/libs/utils";
6
+ import { LOGIN_PROVIDER } from "@arcblock/ux/lib/Util/constant";
7
+ import { SessionContext } from "@arcblock/did-connect/lib/Session";
8
+ import ThirdPartyItem from "./third-party-item.js";
9
+ export default function ThirdPartyLogin({ user }) {
10
+ const { session } = useContext(SessionContext);
11
+ const [oauthConfigs, setOauthConfigs] = useState({});
12
+ const { getOAuthConfigs } = session.useOAuth();
13
+ useAsyncEffect(async () => {
14
+ const data = await getOAuthConfigs({
15
+ sourceAppPid: user?.sourceAppPid
16
+ });
17
+ setOauthConfigs(data);
18
+ }, [user?.sourceAppPid]);
19
+ const availableProviders = useCreation(() => {
20
+ const oauthList = Object.keys(oauthConfigs).map((x) => {
21
+ return {
22
+ ...oauthConfigs[x],
23
+ provider: x
24
+ };
25
+ }).filter((x) => x.enabled);
26
+ return oauthList;
27
+ }, [oauthConfigs]);
28
+ const normalizedAccounts = useCreation(() => {
29
+ const connectedAccounts = getConnectedAccounts(user);
30
+ let removeAuth0 = false;
31
+ let patchProvider = "";
32
+ let sourceProvider = getSourceProvider(user);
33
+ const auth0ConnectedAccount = connectedAccounts.find((x) => x.provider === LOGIN_PROVIDER.AUTH0);
34
+ if (auth0ConnectedAccount) {
35
+ if (auth0ConnectedAccount.id.startsWith("google-oauth2|")) {
36
+ if (!connectedAccounts.some((x) => x.provider === "google")) {
37
+ removeAuth0 = true;
38
+ patchProvider = LOGIN_PROVIDER.GOOGLE;
39
+ if (sourceProvider === LOGIN_PROVIDER.AUTH0) {
40
+ sourceProvider = LOGIN_PROVIDER.GOOGLE;
41
+ }
42
+ }
43
+ }
44
+ if (auth0ConnectedAccount.id.startsWith("appleid|")) {
45
+ if (!connectedAccounts.some((x) => x.provider === LOGIN_PROVIDER.APPLE)) {
46
+ removeAuth0 = true;
47
+ patchProvider = LOGIN_PROVIDER.APPLE;
48
+ if (sourceProvider === LOGIN_PROVIDER.AUTH0) {
49
+ sourceProvider = LOGIN_PROVIDER.APPLE;
50
+ }
51
+ }
52
+ }
53
+ if (auth0ConnectedAccount.id.startsWith("github|")) {
54
+ if (!connectedAccounts.some((x) => x.provider === LOGIN_PROVIDER.GITHUB)) {
55
+ removeAuth0 = true;
56
+ patchProvider = LOGIN_PROVIDER.GITHUB;
57
+ if (sourceProvider === LOGIN_PROVIDER.AUTH0) {
58
+ sourceProvider = LOGIN_PROVIDER.GITHUB;
59
+ }
60
+ }
61
+ }
62
+ }
63
+ const transformedProviders = availableProviders.map((x) => {
64
+ if (x.provider === LOGIN_PROVIDER.AUTH0 && removeAuth0) {
65
+ return null;
66
+ }
67
+ const findConnectedAccount = removeAuth0 && x.provider === patchProvider ? connectedAccounts.find((i) => i.provider === LOGIN_PROVIDER.AUTH0) : connectedAccounts.find((i) => i.provider === x.provider);
68
+ if (findConnectedAccount) {
69
+ return {
70
+ ...x,
71
+ provider: x.provider,
72
+ did: findConnectedAccount.did,
73
+ pk: findConnectedAccount.pk,
74
+ userInfo: findConnectedAccount.userInfo,
75
+ _bind: true,
76
+ _rawProvider: findConnectedAccount.provider,
77
+ _mainProvider: x.provider === sourceProvider
78
+ };
79
+ }
80
+ return {
81
+ ...x,
82
+ provider: x.provider,
83
+ _rawProvider: x.provider,
84
+ _mainProvider: x.provider === sourceProvider
85
+ };
86
+ }).filter(Boolean).sort((a, b) => {
87
+ if (a?.order !== void 0 && b?.order !== void 0) {
88
+ return a.order - b.order;
89
+ }
90
+ if (a?.order !== void 0) {
91
+ return -1;
92
+ }
93
+ return 1;
94
+ });
95
+ return transformedProviders;
96
+ }, [user?.connectedAccounts, availableProviders]);
97
+ return /* @__PURE__ */ jsx(
98
+ List,
99
+ {
100
+ dense: true,
101
+ sx: {
102
+ gap: 1,
103
+ display: "flex",
104
+ flexDirection: "column"
105
+ },
106
+ children: normalizedAccounts.map((account) => {
107
+ return /* @__PURE__ */ jsx(ThirdPartyItem, { item: account }, account?.provider);
108
+ })
109
+ }
110
+ );
111
+ }
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import type { OAuthAccount } from '../../../@types';
3
+ export default function ThirdPartyItem({ item, }: {
4
+ item: {
5
+ provider: string;
6
+ did: string;
7
+ pk: string;
8
+ userInfo?: OAuthAccount['userInfo'];
9
+ _bind?: boolean;
10
+ _rawProvider?: string;
11
+ _mainProvider?: boolean;
12
+ };
13
+ }): import("react").JSX.Element;
@@ -0,0 +1,227 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { Icon } from "@iconify/react";
3
+ import { Box, ListItem, Tooltip, Typography } from "@mui/material";
4
+ import LinkRoundedIcon from "@iconify-icons/material-symbols/link-rounded";
5
+ import { temp as colors } from "@arcblock/ux/lib/Colors";
6
+ import Button from "@arcblock/ux/lib/Button";
7
+ import Avatar from "@arcblock/ux/lib/Avatar";
8
+ import { useCreation, useMemoizedFn, useReactive } from "ahooks";
9
+ import { translate } from "@arcblock/ux/lib/Locale/util";
10
+ import { useConfirm } from "@arcblock/ux/lib/Dialog";
11
+ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
12
+ import MailOutlineRoundedIcon from "@iconify-icons/material-symbols/mail-outline-rounded";
13
+ import InfoOutlineRoundedIcon from "@iconify-icons/material-symbols/info-outline-rounded";
14
+ import AppleIcon from "@iconify-icons/logos/apple";
15
+ import GithubIcon from "@iconify-icons/logos/github-icon";
16
+ import GoogleIcon from "@iconify-icons/logos/google-icon";
17
+ import { SessionContext } from "@arcblock/did-connect/lib/Session";
18
+ import { useContext } from "react";
19
+ import pick from "lodash/pick";
20
+ import { getFederatedEnabled, getMaster } from "@arcblock/ux/lib/Util/federated";
21
+ import { LOGIN_PROVIDER, OAUTH_PROVIDER } from "@arcblock/ux/lib/Util/constant";
22
+ import { translations } from "../../libs/locales.js";
23
+ export default function ThirdPartyItem({
24
+ item
25
+ }) {
26
+ const { confirmApi, confirmHolder } = useConfirm();
27
+ const currentState = useReactive({
28
+ loading: false
29
+ });
30
+ const { locale } = useLocaleContext();
31
+ const t = useMemoizedFn((key, data = {}) => {
32
+ return translate(translations, key, locale, "en", data);
33
+ });
34
+ const { session } = useContext(SessionContext);
35
+ const { bindOAuth, unbindOAuth, setBaseUrl, baseUrl: oauthBaseUrl } = session.useOAuth();
36
+ const iconMap = {
37
+ // email: MailOutlineRoundedIcon,
38
+ [LOGIN_PROVIDER.AUTH0]: MailOutlineRoundedIcon,
39
+ [LOGIN_PROVIDER.APPLE]: AppleIcon,
40
+ [LOGIN_PROVIDER.GITHUB]: GithubIcon,
41
+ [LOGIN_PROVIDER.GOOGLE]: GoogleIcon
42
+ };
43
+ const icon = useCreation(() => {
44
+ return iconMap[item?.provider];
45
+ }, [item?.provider]);
46
+ const title = useCreation(() => {
47
+ return OAUTH_PROVIDER[item?.provider] || "unknown";
48
+ }, [item?.provider]);
49
+ const toggleBind = useMemoizedFn(async () => {
50
+ try {
51
+ currentState.loading = true;
52
+ await new Promise((resolve, reject) => {
53
+ if (item?._bind) {
54
+ confirmApi.open({
55
+ title: t("thirdPartyLogin.confirmUnbind", { name: title }),
56
+ content: t("thirdPartyLogin.confirmUnbindDescription", { name: title }),
57
+ confirmButtonText: t("common.confirm"),
58
+ cancelButtonText: t("common.cancel"),
59
+ onConfirm(close) {
60
+ unbindOAuth({
61
+ session,
62
+ connectedAccount: {
63
+ ...pick(item, ["did", "pk"]),
64
+ showProvider: item.provider,
65
+ provider: item._rawProvider
66
+ }
67
+ }).then(resolve).catch(reject);
68
+ close();
69
+ },
70
+ onCancel: resolve
71
+ });
72
+ } else {
73
+ const backupBaseUrl = oauthBaseUrl;
74
+ const blocklet = window?.blocklet;
75
+ let baseUrl = "/";
76
+ const federatedEnabled = getFederatedEnabled(blocklet);
77
+ const master = getMaster(blocklet);
78
+ if (federatedEnabled && master?.appPid && session?.user?.sourceAppPid) {
79
+ baseUrl = master.appUrl;
80
+ }
81
+ setBaseUrl(baseUrl);
82
+ bindOAuth({
83
+ session,
84
+ oauthItem: {
85
+ ...item,
86
+ provider: item._rawProvider
87
+ }
88
+ }).then(resolve).catch(reject).finally(() => {
89
+ setBaseUrl(backupBaseUrl);
90
+ });
91
+ }
92
+ });
93
+ } catch (err) {
94
+ console.error(`Failed to ${item?._bind ? "unbind" : "bind"} oauth account`, err);
95
+ } finally {
96
+ currentState.loading = false;
97
+ }
98
+ });
99
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
100
+ /* @__PURE__ */ jsxs(
101
+ ListItem,
102
+ {
103
+ disablePadding: true,
104
+ sx: {
105
+ display: "flex",
106
+ alignItems: "center",
107
+ gap: 1
108
+ },
109
+ children: [
110
+ /* @__PURE__ */ jsxs(
111
+ Box,
112
+ {
113
+ sx: {
114
+ flex: 1,
115
+ borderRadius: 2,
116
+ border: `1px solid ${colors.strokeBorderBase}`,
117
+ background: colors.backgroundsBgField,
118
+ display: "flex",
119
+ alignItems: "center",
120
+ py: 1,
121
+ px: 1.5,
122
+ gap: 0.75,
123
+ fontSize: "14px",
124
+ lineHeight: 1
125
+ },
126
+ children: [
127
+ /* @__PURE__ */ jsx(Icon, { icon, fontSize: 16 }),
128
+ /* @__PURE__ */ jsx(
129
+ Box,
130
+ {
131
+ sx: {
132
+ display: "flex",
133
+ alignItems: "center",
134
+ justifyContent: "space-between",
135
+ flex: 1,
136
+ gap: 1
137
+ },
138
+ children: title
139
+ }
140
+ ),
141
+ /* @__PURE__ */ jsxs(
142
+ Box,
143
+ {
144
+ sx: {
145
+ display: "flex",
146
+ alignItems: "center",
147
+ gap: 0.5
148
+ },
149
+ children: [
150
+ item.userInfo?.email || item.did,
151
+ item.userInfo?.email ? /* @__PURE__ */ jsx(
152
+ Tooltip,
153
+ {
154
+ title: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
155
+ /* @__PURE__ */ jsx(Avatar, { size: 36, variant: "circle", shape: "circle", src: item.userInfo?.picture, did: item.did }),
156
+ /* @__PURE__ */ jsxs(Box, { children: [
157
+ /* @__PURE__ */ jsx(
158
+ Typography,
159
+ {
160
+ sx: {
161
+ whiteSpace: "normal",
162
+ wordBreak: "break-all",
163
+ fontSize: "0.9rem"
164
+ },
165
+ children: item.userInfo?.name
166
+ }
167
+ ),
168
+ /* @__PURE__ */ jsx(
169
+ Typography,
170
+ {
171
+ sx: {
172
+ whiteSpace: "normal",
173
+ wordBreak: "break-all",
174
+ fontSize: "0.9rem"
175
+ },
176
+ children: item.userInfo?.email
177
+ }
178
+ )
179
+ ] })
180
+ ] }) }),
181
+ children: /* @__PURE__ */ jsx(
182
+ Icon,
183
+ {
184
+ icon: InfoOutlineRoundedIcon,
185
+ color: colors.textSubtitle,
186
+ fontSize: 16,
187
+ style: { cursor: "pointer" }
188
+ }
189
+ )
190
+ }
191
+ ) : null
192
+ ]
193
+ }
194
+ )
195
+ ]
196
+ }
197
+ ),
198
+ /* @__PURE__ */ jsx(Tooltip, { title: item._mainProvider ? t("thirdPartyLogin.mainProviderCantRemove") : "", children: /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
199
+ Button,
200
+ {
201
+ variant: "outlined",
202
+ size: "small",
203
+ sx: {
204
+ color: item?._bind ? colors.red : colors.foregroundsFgBase,
205
+ borderColor: item?._bind ? colors.red : colors.strokeBorderBase,
206
+ backgroundColor: colors.buttonsButtonNeutral,
207
+ "&:hover": {
208
+ borderColor: item?._bind ? colors.red : colors.strokeBorderBase,
209
+ backgroundColor: colors.buttonsButtonNeutralHover
210
+ },
211
+ py: 0.5,
212
+ borderRadius: 2,
213
+ fontWeight: 500
214
+ },
215
+ startIcon: currentState.loading ? null : /* @__PURE__ */ jsx(Icon, { icon: LinkRoundedIcon }),
216
+ onClick: toggleBind,
217
+ disabled: item._mainProvider,
218
+ loading: currentState.loading,
219
+ children: item?._bind ? t("thirdPartyLogin.disconnect") : t("thirdPartyLogin.connect")
220
+ }
221
+ ) }) })
222
+ ]
223
+ }
224
+ ),
225
+ confirmHolder
226
+ ] });
227
+ }
@@ -1,7 +1,7 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useContext } from "react";
3
3
  import { Box, CircularProgress, Typography } from "@mui/material";
4
- import { useCreation, useMemoizedFn, useMount, useRequest } from "ahooks";
4
+ import { useCreation, useMemoizedFn, useMount, useRequest, useUpdateEffect } from "ahooks";
5
5
  import pWaitFor from "p-wait-for";
6
6
  import { SessionContext } from "@arcblock/did-connect/lib/Session";
7
7
  import Tabs from "@arcblock/ux/lib/Tabs";
@@ -17,8 +17,7 @@ import { getQuery, withQuery } from "ufo";
17
17
  import Footer from "../../Footer/index.js";
18
18
  import Header from "../../Header/index.js";
19
19
  import { translations } from "../libs/locales.js";
20
- import UserInfo from "./user-info.js";
21
- import UserBasicInfo from "./user-basic-info.js";
20
+ import { UserInfo, UserBasicInfo } from "./user-info/index.js";
22
21
  import { formatBlockletInfo, getLocalizedNavigation } from "../../blocklets.js";
23
22
  import Passport from "./passport.js";
24
23
  import Settings from "./settings.js";
@@ -73,7 +72,7 @@ export default function UserCenter({
73
72
  }
74
73
  },
75
74
  {
76
- refreshDeps: [currentDid, isMyself, session?.initialized]
75
+ refreshDeps: [currentDid, isMyself, session?.initialized, session?.user]
77
76
  }
78
77
  );
79
78
  const privacyState = useRequest(
@@ -143,27 +142,33 @@ export default function UserCenter({
143
142
  });
144
143
  }
145
144
  });
145
+ const settingContent = useCreation(() => {
146
+ return /* @__PURE__ */ jsx(
147
+ Settings,
148
+ {
149
+ user: userState.data,
150
+ settings: { userCenterTabs },
151
+ onSave: async () => {
152
+ await privacyState.runAsync();
153
+ return privacyState.data;
154
+ }
155
+ }
156
+ );
157
+ }, [userState.data]);
146
158
  const openSettings = useMemoizedFn(() => {
147
159
  confirmApi.open({
148
160
  title: t("settings"),
149
- content: /* @__PURE__ */ jsx(
150
- Settings,
151
- {
152
- user: userState.data,
153
- settings: {
154
- userCenterTabs
155
- },
156
- onSave: async () => {
157
- await privacyState.runAsync();
158
- return privacyState.data;
159
- }
160
- }
161
- ),
161
+ content: settingContent,
162
162
  showCancelButton: false,
163
163
  confirmButtonText: t("done"),
164
164
  onConfirm: confirmApi.close
165
165
  });
166
166
  });
167
+ useUpdateEffect(() => {
168
+ confirmApi.update({
169
+ content: settingContent
170
+ });
171
+ }, [settingContent]);
167
172
  useMount(() => {
168
173
  if (autoPopupSetting) {
169
174
  openSettings();
@@ -0,0 +1,3 @@
1
+ export { default as UserBasicInfo } from './user-basic-info';
2
+ export { default as UserInfoItem } from './user-info-item';
3
+ export { default as UserInfo } from './user-info';
@@ -0,0 +1,3 @@
1
+ export { default as UserBasicInfo } from "./user-basic-info.js";
2
+ export { default as UserInfoItem } from "./user-info-item.js";
3
+ export { default as UserInfo } from "./user-info.js";
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { BoxProps } from '@mui/material';
3
- import type { User } from '../../@types';
3
+ import type { User } from '../../../@types';
4
4
  export default function UserBasicInfo({ user, isMyself, showFullDid, switchPassport, switchProfile, openSettings, ...rest }: {
5
5
  user: User;
6
6
  isMyself?: boolean;
@@ -11,7 +11,7 @@ import { useCreation, useMemoizedFn } from "ahooks";
11
11
  import { translate } from "@arcblock/ux/lib/Locale/util";
12
12
  import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
13
13
  import noop from "lodash/noop";
14
- import { translations } from "../libs/locales.js";
14
+ import { translations } from "../../libs/locales.js";
15
15
  export default function UserBasicInfo({
16
16
  user,
17
17
  isMyself = true,
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { BoxProps } from '@mui/material';
3
- import type { User } from '../../@types';
3
+ import type { User } from '../../../@types';
4
4
  export default function UserInfo({ user, ...rest }: {
5
5
  user: User;
6
6
  } & BoxProps): import("react").JSX.Element;
@@ -10,7 +10,8 @@ import SettingsInputAntennaRoundedIcon from "@iconify-icons/material-symbols/set
10
10
  import RelativeTime from "@arcblock/ux/lib/RelativeTime";
11
11
  import { translate } from "@arcblock/ux/lib/Locale/util";
12
12
  import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
13
- import { translations } from "../libs/locales.js";
13
+ import { LOGIN_PROVIDER_NAME } from "@arcblock/ux/lib/Util/constant";
14
+ import { translations } from "../../libs/locales.js";
14
15
  import UserInfoItem from "./user-info-item.js";
15
16
  export default function UserInfo({
16
17
  user,
@@ -21,11 +22,7 @@ export default function UserInfo({
21
22
  return translate(translations, key, locale, "en", data);
22
23
  });
23
24
  const readableProvider = useCreation(() => {
24
- const nameMap = {
25
- wallet: "DID Wallet",
26
- auth0: "Auth0"
27
- };
28
- return user?.sourceProvider && nameMap[user.sourceProvider] || t("unknown");
25
+ return user?.sourceProvider && LOGIN_PROVIDER_NAME[user.sourceProvider] || t("unknown");
29
26
  }, [user?.sourceProvider]);
30
27
  const userInfoListData = [];
31
28
  userInfoListData.push({
@@ -31,6 +31,8 @@ export declare const translations: {
31
31
  slack: string;
32
32
  };
33
33
  common: {
34
+ confirm: string;
35
+ cancel: string;
34
36
  required: string;
35
37
  invalid: string;
36
38
  };
@@ -68,6 +70,14 @@ export declare const translations: {
68
70
  };
69
71
  };
70
72
  };
73
+ thirdPartyLogin: {
74
+ title: string;
75
+ connect: string;
76
+ disconnect: string;
77
+ mainProviderCantRemove: string;
78
+ confirmUnbind: string;
79
+ confirmUnbindDescription: string;
80
+ };
71
81
  };
72
82
  en: {
73
83
  settings: string;
@@ -101,6 +111,8 @@ export declare const translations: {
101
111
  slack: string;
102
112
  };
103
113
  common: {
114
+ confirm: string;
115
+ cancel: string;
104
116
  required: string;
105
117
  invalid: string;
106
118
  };
@@ -138,5 +150,13 @@ export declare const translations: {
138
150
  };
139
151
  };
140
152
  };
153
+ thirdPartyLogin: {
154
+ title: string;
155
+ connect: string;
156
+ disconnect: string;
157
+ mainProviderCantRemove: string;
158
+ confirmUnbind: string;
159
+ confirmUnbindDescription: string;
160
+ };
141
161
  };
142
162
  };