@blocklet/ui-react 2.9.17 → 2.9.19

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 (104) hide show
  1. package/build.config.ts +1 -1
  2. package/es/@types/index.d.ts +2 -0
  3. package/es/Dashboard/index.js +1 -1
  4. package/es/UserCenter/components/settings.d.ts +1 -2
  5. package/es/UserCenter/components/settings.js +8 -1
  6. package/es/UserCenter/components/storage/connect-to.d.ts +7 -0
  7. package/es/UserCenter/components/storage/connect-to.js +104 -0
  8. package/es/UserCenter/components/storage/connected.d.ts +7 -0
  9. package/es/UserCenter/components/storage/connected.js +21 -0
  10. package/es/UserCenter/components/storage/delete.d.ts +7 -0
  11. package/es/UserCenter/components/storage/delete.js +59 -0
  12. package/es/UserCenter/components/storage/disconnect.d.ts +3 -0
  13. package/es/UserCenter/components/storage/disconnect.js +23 -0
  14. package/es/UserCenter/components/storage/icons/empty-spaces-nft.svg +58 -0
  15. package/es/UserCenter/components/storage/icons/long-arrow.svg +5 -0
  16. package/es/UserCenter/components/storage/icons/space-connected.svg +3 -0
  17. package/es/UserCenter/components/storage/icons/space-disconnect.svg +3 -0
  18. package/es/UserCenter/components/storage/index.d.ts +3 -0
  19. package/es/UserCenter/components/storage/index.js +25 -0
  20. package/es/UserCenter/components/storage/item.d.ts +9 -0
  21. package/es/UserCenter/components/storage/item.js +147 -0
  22. package/es/UserCenter/components/storage/preview-nft.d.ts +6 -0
  23. package/es/UserCenter/components/storage/preview-nft.js +80 -0
  24. package/es/UserCenter/components/user-basic-info.d.ts +3 -1
  25. package/es/UserCenter/components/user-basic-info.js +133 -46
  26. package/es/UserCenter/components/user-center.d.ts +9 -6
  27. package/es/UserCenter/components/user-center.js +39 -138
  28. package/es/UserCenter/components/user-info-item.d.ts +2 -1
  29. package/es/UserCenter/components/user-info-item.js +4 -2
  30. package/es/UserCenter/components/user-info.js +6 -2
  31. package/es/UserCenter/libs/api.d.ts +3 -0
  32. package/es/UserCenter/libs/api.js +4 -0
  33. package/es/UserCenter/libs/locales.d.ts +6 -0
  34. package/es/UserCenter/libs/locales.js +8 -2
  35. package/es/contexts/config-user-space.d.ts +26 -0
  36. package/es/contexts/config-user-space.js +53 -0
  37. package/es/hooks/use-mobile.d.ts +4 -0
  38. package/es/hooks/use-mobile.js +5 -0
  39. package/es/libs/spaces.d.ts +1 -0
  40. package/es/libs/spaces.js +7 -0
  41. package/lib/@types/index.d.ts +2 -0
  42. package/lib/Dashboard/index.js +2 -0
  43. package/lib/UserCenter/components/settings.d.ts +1 -2
  44. package/lib/UserCenter/components/settings.js +9 -1
  45. package/lib/UserCenter/components/storage/connect-to.d.ts +7 -0
  46. package/lib/UserCenter/components/storage/connect-to.js +127 -0
  47. package/lib/UserCenter/components/storage/connected.d.ts +7 -0
  48. package/lib/UserCenter/components/storage/connected.js +45 -0
  49. package/lib/UserCenter/components/storage/delete.d.ts +7 -0
  50. package/lib/UserCenter/components/storage/delete.js +71 -0
  51. package/lib/UserCenter/components/storage/disconnect.d.ts +3 -0
  52. package/lib/UserCenter/components/storage/disconnect.js +37 -0
  53. package/lib/UserCenter/components/storage/icons/empty-spaces-nft.svg +58 -0
  54. package/lib/UserCenter/components/storage/icons/long-arrow.svg +5 -0
  55. package/lib/UserCenter/components/storage/icons/space-connected.svg +3 -0
  56. package/lib/UserCenter/components/storage/icons/space-disconnect.svg +3 -0
  57. package/lib/UserCenter/components/storage/index.d.ts +3 -0
  58. package/lib/UserCenter/components/storage/index.js +56 -0
  59. package/lib/UserCenter/components/storage/item.d.ts +9 -0
  60. package/lib/UserCenter/components/storage/item.js +179 -0
  61. package/lib/UserCenter/components/storage/preview-nft.d.ts +6 -0
  62. package/lib/UserCenter/components/storage/preview-nft.js +88 -0
  63. package/lib/UserCenter/components/user-basic-info.d.ts +3 -1
  64. package/lib/UserCenter/components/user-basic-info.js +81 -4
  65. package/lib/UserCenter/components/user-center.d.ts +9 -6
  66. package/lib/UserCenter/components/user-center.js +36 -95
  67. package/lib/UserCenter/components/user-info-item.d.ts +2 -1
  68. package/lib/UserCenter/components/user-info-item.js +5 -2
  69. package/lib/UserCenter/components/user-info.js +9 -2
  70. package/lib/UserCenter/libs/api.d.ts +3 -0
  71. package/lib/UserCenter/libs/api.js +16 -0
  72. package/lib/UserCenter/libs/locales.d.ts +6 -0
  73. package/lib/UserCenter/libs/locales.js +8 -2
  74. package/lib/contexts/config-user-space.d.ts +26 -0
  75. package/lib/contexts/config-user-space.js +61 -0
  76. package/lib/hooks/use-mobile.d.ts +4 -0
  77. package/lib/hooks/use-mobile.js +13 -0
  78. package/lib/libs/spaces.d.ts +1 -0
  79. package/lib/libs/spaces.js +13 -0
  80. package/package.json +6 -4
  81. package/src/@types/index.ts +3 -0
  82. package/src/Dashboard/index.jsx +1 -1
  83. package/src/UserCenter/components/settings.tsx +8 -2
  84. package/src/UserCenter/components/storage/connect-to.tsx +117 -0
  85. package/src/UserCenter/components/storage/connected.tsx +29 -0
  86. package/src/UserCenter/components/storage/delete.tsx +66 -0
  87. package/src/UserCenter/components/storage/disconnect.tsx +27 -0
  88. package/src/UserCenter/components/storage/icons/empty-spaces-nft.svg +58 -0
  89. package/src/UserCenter/components/storage/icons/long-arrow.svg +5 -0
  90. package/src/UserCenter/components/storage/icons/space-connected.svg +3 -0
  91. package/src/UserCenter/components/storage/icons/space-disconnect.svg +3 -0
  92. package/src/UserCenter/components/storage/index.tsx +47 -0
  93. package/src/UserCenter/components/storage/item.tsx +150 -0
  94. package/src/UserCenter/components/storage/preview-nft.tsx +72 -0
  95. package/src/UserCenter/components/user-basic-info.tsx +88 -5
  96. package/src/UserCenter/components/user-center.tsx +36 -115
  97. package/src/UserCenter/components/user-info-item.tsx +4 -2
  98. package/src/UserCenter/components/user-info.tsx +6 -2
  99. package/src/UserCenter/libs/api.ts +7 -0
  100. package/src/UserCenter/libs/locales.ts +6 -0
  101. package/src/contexts/config-user-space.tsx +86 -0
  102. package/src/hooks/use-mobile.tsx +6 -0
  103. package/src/libs/spaces.tsx +10 -0
  104. package/babel.config.es.js +0 -8
@@ -1,38 +1,98 @@
1
- import { Box, Chip, Typography } from '@mui/material';
1
+ import { Box, Chip, IconButton, Typography } from '@mui/material';
2
2
  import type { BoxProps } from '@mui/material';
3
3
  import { Icon } from '@iconify/react';
4
4
  import SwapHorizRoundedIcon from '@iconify-icons/material-symbols/swap-horiz-rounded';
5
+ import SettingsOutlineRoundedIcon from '@iconify-icons/material-symbols/settings-outline-rounded';
6
+ import Avatar from '@arcblock/ux/lib/Avatar';
5
7
  import { temp as colors } from '@arcblock/ux/lib/Colors';
8
+ import { useTheme } from '@arcblock/ux/lib/Theme';
6
9
  import DID from '@arcblock/ux/lib/DID';
7
- import { useCreation } from 'ahooks';
10
+ import { useCreation, useMemoizedFn } from 'ahooks';
11
+ import { translate } from '@arcblock/ux/lib/Locale/util';
12
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
13
+ import noop from 'lodash/noop';
8
14
 
15
+ import { translations } from '../libs/locales';
9
16
  import type { User } from '../../@types';
10
17
 
11
18
  export default function UserBasicInfo({
12
19
  user,
13
20
  isMyself = true,
14
21
  switchPassport,
22
+ switchProfile,
23
+ openSettings,
15
24
  ...rest
16
25
  }: {
17
26
  user: User;
18
27
  isMyself: boolean;
19
28
  switchPassport: () => void;
29
+ switchProfile: () => void;
30
+ openSettings: () => void;
20
31
  } & BoxProps) {
32
+ const { locale } = useLocaleContext();
33
+ const t = useMemoizedFn((key, data = {}) => {
34
+ return translate(translations, key, locale, 'en', data);
35
+ });
21
36
  const currentRole = useCreation(
22
37
  () => (user?.passports || [])?.find((item) => item.name === user.role),
23
38
  [user?.passports, user?.role]
24
39
  );
40
+ const theme = useTheme();
41
+
42
+ const isSmallView = theme.breakpoints.down('md');
25
43
 
26
44
  return (
27
- <Box {...rest}>
45
+ <Box
46
+ {...rest}
47
+ sx={{
48
+ position: 'relative',
49
+ ...rest.sx,
50
+ }}>
51
+ <Avatar
52
+ src={user?.avatar}
53
+ did={user?.did}
54
+ size={isSmallView ? 64 : 80}
55
+ variant="circle"
56
+ shape="circle"
57
+ sx={{
58
+ borderRadius: '100%',
59
+ backgroundColor: '#fff',
60
+ position: 'relative',
61
+ overflow: 'hidden',
62
+ ...(isMyself
63
+ ? {
64
+ cursor: 'pointer',
65
+ '&:hover': {
66
+ '&::after': {
67
+ content: `"${t('switchProfile')}"`,
68
+ },
69
+ },
70
+ '&::after': {
71
+ color: 'white',
72
+ position: 'absolute',
73
+ fontSize: '12px',
74
+ bottom: 0,
75
+ left: 0,
76
+ right: 0,
77
+ height: '50%',
78
+ backgroundColor: 'rgba(0, 0, 0, 0.3)',
79
+ display: 'flex',
80
+ justifyContent: 'center',
81
+ alignItems: 'center',
82
+ },
83
+ }
84
+ : {}),
85
+ }}
86
+ onClick={isMyself ? switchProfile : noop}
87
+ />
28
88
  <Typography
29
- variant="h4"
89
+ variant="h5"
30
90
  sx={{
31
91
  fontWeight: 'bold',
32
92
  display: 'flex',
33
93
  alignItems: 'center',
34
94
  gap: 1,
35
- mb: 1,
95
+ fontSize: '24px !important',
36
96
  }}>
37
97
  {user?.fullName}
38
98
  {isMyself ? (
@@ -65,6 +125,29 @@ export default function UserBasicInfo({
65
125
  ) : null}
66
126
  </Typography>
67
127
  <DID did={user.did} copyable={false} />
128
+ {isMyself ? (
129
+ <IconButton
130
+ sx={{
131
+ borderRadius: 2,
132
+ color: colors.textBase,
133
+ backgroundColor: 'white',
134
+ border: `1px solid ${colors.strokeBorderBase}`,
135
+ position: 'absolute',
136
+ bottom: {
137
+ xs: 'unset',
138
+ md: 0,
139
+ },
140
+ top: {
141
+ xs: 0,
142
+ md: 'unset',
143
+ },
144
+ right: 0,
145
+ }}
146
+ disableFocusRipple
147
+ onClick={openSettings}>
148
+ <Icon icon={SettingsOutlineRoundedIcon} />
149
+ </IconButton>
150
+ ) : null}
68
151
  </Box>
69
152
  );
70
153
  }
@@ -1,11 +1,10 @@
1
1
  import { useContext } from 'react';
2
- import { Box, CircularProgress, IconButton, Paper, Typography } from '@mui/material';
2
+ import { Box, CircularProgress, Paper, Typography } from '@mui/material';
3
3
  import type { PaperProps } from '@mui/material';
4
4
  import { useCreation, useMemoizedFn, useMount, useRequest } from 'ahooks';
5
- import { Icon } from '@iconify/react';
6
- import SettingsOutlineRoundedIcon from '@iconify-icons/material-symbols/settings-outline-rounded';
5
+
7
6
  import { SessionContext } from '@arcblock/did-connect/lib/Session';
8
- import Avatar from '@arcblock/ux/lib/Avatar';
7
+
9
8
  import Tabs from '@arcblock/ux/lib/Tabs';
10
9
  import Empty from '@arcblock/ux/lib/Empty';
11
10
  import { temp as colors } from '@arcblock/ux/lib/Colors';
@@ -17,10 +16,8 @@ import cloneDeep from 'lodash/cloneDeep';
17
16
  import { getQuery, withQuery } from 'ufo';
18
17
  import type { AxiosError } from 'axios';
19
18
 
20
- // @ts-ignore
21
- import Header from '../../Header';
19
+ import { Header, Footer } from '../../';
22
20
  import { translations } from '../libs/locales';
23
- import banner from '../assets/banner.png';
24
21
  import UserInfo from './user-info';
25
22
  import UserBasicInfo from './user-basic-info';
26
23
  import type { SessionContext as TSessionContext, UserCenterTab } from '../../@types';
@@ -36,12 +33,18 @@ export default function UserCenter({
36
33
  contentProps = {},
37
34
  disableAutoRedirect = false,
38
35
  autoPopupSetting = false,
36
+ hideFooter = false,
37
+ headerProps = {},
38
+ footerProps = {},
39
39
  }: {
40
- children: any;
41
- currentTab: string;
42
- contentProps?: PaperProps;
43
- disableAutoRedirect?: boolean;
44
- autoPopupSetting?: boolean;
40
+ readonly children: any;
41
+ readonly currentTab: string;
42
+ readonly contentProps?: PaperProps;
43
+ readonly disableAutoRedirect?: boolean;
44
+ readonly autoPopupSetting?: boolean;
45
+ readonly hideFooter?: boolean;
46
+ readonly headerProps?: object;
47
+ readonly footerProps?: object;
45
48
  }) {
46
49
  const { locale } = useLocaleContext();
47
50
  const t = useMemoizedFn((key, data = {}) => {
@@ -157,27 +160,6 @@ export default function UserCenter({
157
160
  });
158
161
  }
159
162
  });
160
- const xsGridTemplateAreas = useCreation(() => {
161
- return [
162
- '"avatar settings"',
163
- '"basicInfo basicInfo"',
164
- userCenterTabs.length > 0 || !isMyself ? '"tabs tabs"' : null,
165
- isMyself ? '"passport passport"' : null,
166
- isMyself ? '"extraInfo extraInfo"' : null,
167
- ];
168
- }, [userCenterTabs, isMyself]);
169
-
170
- const mdGridTemplateAreas = useCreation(() => {
171
- if (!isMyself) {
172
- return ['"avatar"', '"basicInfo"', '"tabs"'];
173
- }
174
- return [
175
- '"avatar settings"',
176
- '"basicInfo extraInfo"',
177
- userCenterTabs.length > 0 ? '"tabs extraInfo"' : null,
178
- '"passport extraInfo"',
179
- ];
180
- }, [userCenterTabs, isMyself]);
181
163
 
182
164
  const openSettings = useMemoizedFn(() => {
183
165
  confirmApi.open({
@@ -226,69 +208,19 @@ export default function UserCenter({
226
208
  return (
227
209
  <Box
228
210
  sx={{
229
- maxWidth: 1200,
211
+ maxWidth: 880,
230
212
  margin: '0 auto',
231
- px: 3,
232
- pb: 3,
233
- display: 'grid',
213
+ p: 3,
214
+ display: 'flex',
234
215
  gap: 2.5,
235
- gridTemplateAreas: {
236
- xs: xsGridTemplateAreas.filter(Boolean).join(' '),
237
- md: mdGridTemplateAreas.filter(Boolean).join(' '),
238
- },
239
- gridTemplateRows: {
240
- xs: '64px auto auto auto',
241
- md: '64px auto 1fr',
242
- },
243
- gridTemplateColumns: {
244
- xs: '1fr',
245
- md: isMyself ? '1fr 300px' : '1fr',
246
- },
216
+ flexDirection: 'column',
247
217
  }}>
248
- <Box>
249
- <Avatar
250
- src={userState.data?.avatar}
251
- did={userState.data?.did}
252
- size={120}
253
- variant="circle"
254
- shape="circle"
255
- style={{
256
- border: '4px solid #fff',
257
- transform: 'translateY(-50%)',
258
- borderRadius: '100%',
259
- gridArea: 'avatar',
260
- backgroundColor: '#fff',
261
- }}
262
- />
263
- </Box>
264
- {isMyself ? (
265
- <Box
266
- sx={{
267
- gridArea: 'settings',
268
- display: 'flex',
269
- justifyContent: 'flex-end',
270
- alignItems: 'center',
271
- }}>
272
- <IconButton
273
- sx={{
274
- borderRadius: 2,
275
- color: colors.textBase,
276
- backgroundColor: 'white',
277
- border: `1px solid ${colors.strokeBorderBase}`,
278
- }}
279
- disableFocusRipple
280
- onClick={openSettings}>
281
- <Icon icon={SettingsOutlineRoundedIcon} />
282
- </IconButton>
283
- </Box>
284
- ) : null}
285
218
  <UserBasicInfo
286
219
  isMyself={isMyself}
287
220
  switchPassport={session.switchPassport}
221
+ switchProfile={session.switchProfile}
222
+ openSettings={openSettings}
288
223
  user={userState.data}
289
- sx={{
290
- gridArea: 'basicInfo',
291
- }}
292
224
  />
293
225
  {userCenterTabs.length > 0 && currentTab ? (
294
226
  <Box
@@ -351,19 +283,16 @@ export default function UserCenter({
351
283
  ) : null}
352
284
  {isMyself ? (
353
285
  <>
354
- <Box
355
- sx={{
356
- gridArea: 'passport',
357
- }}>
286
+ <Box>
358
287
  <Typography variant="h5" sx={{ fontWeight: 'bold', mb: 1.5 }}>
359
- Passport
288
+ {t('passport')}
360
289
  </Typography>
361
290
  <Passport user={userState.data} />
362
291
  </Box>
363
- <Box
364
- sx={{
365
- gridArea: 'extraInfo',
366
- }}>
292
+ <Box>
293
+ <Typography variant="h5" sx={{ fontWeight: 'bold', mb: 1.5 }}>
294
+ {t('userInfo')}
295
+ </Typography>
367
296
  <UserInfo
368
297
  user={userState.data}
369
298
  sx={{
@@ -376,7 +305,7 @@ export default function UserCenter({
376
305
  ) : null}
377
306
  </Box>
378
307
  );
379
- }, [userState, userCenterTabs, mdGridTemplateAreas, xsGridTemplateAreas]);
308
+ }, [userState, userCenterTabs]);
380
309
 
381
310
  if (!disableAutoRedirect && !currentTab && formattedBlocklet?.navigation?.userCenter?.length > 0) {
382
311
  window.location.replace(formattedBlocklet?.navigation?.userCenter[0]?.link);
@@ -388,23 +317,15 @@ export default function UserCenter({
388
317
  sx={{
389
318
  backgroundColor: colors.backgroundsBgSubtitle,
390
319
  minHeight: '100vh',
320
+ display: 'flex',
321
+ flexDirection: 'column',
391
322
  }}>
392
- <Header />
393
- <Box
394
- sx={{
395
- pt: {
396
- xs: `${(400 / 1280) * 100}%`,
397
- sm: `${(300 / 1280) * 100}%`,
398
- md: `${(200 / 1280) * 100}%`,
399
- },
400
- backgroundImage: `url(${banner})`,
401
- backgroundSize: 'cover',
402
- minHeight: '60px',
403
- }}
404
- />
405
- {}
406
- {content}
407
- {confirmHolder}
323
+ <Header {...headerProps} />
324
+ <Box flex={1}>
325
+ {content}
326
+ {confirmHolder}
327
+ </Box>
328
+ {hideFooter ? null : <Footer {...footerProps} />}
408
329
  </Box>
409
330
  );
410
331
  }
@@ -1,4 +1,4 @@
1
- import { Box, Typography } from '@mui/material';
1
+ import { Box, BoxProps, Typography } from '@mui/material';
2
2
  import { temp as colors } from '@arcblock/ux/lib/Colors';
3
3
 
4
4
  type TUserInfoItemProps = {
@@ -9,9 +9,10 @@ type TUserInfoItemProps = {
9
9
  };
10
10
  };
11
11
 
12
- export default function UserInfoItem({ data }: TUserInfoItemProps) {
12
+ export default function UserInfoItem({ data, ...rest }: TUserInfoItemProps & BoxProps) {
13
13
  return (
14
14
  <Box
15
+ {...rest}
15
16
  sx={{
16
17
  display: 'grid',
17
18
  gridTemplateColumns: 'auto 1fr',
@@ -19,6 +20,7 @@ export default function UserInfoItem({ data }: TUserInfoItemProps) {
19
20
  alignItems: 'center',
20
21
  rowGap: 0.75,
21
22
  columnGap: 1,
23
+ ...rest.sx,
22
24
  }}>
23
25
  <Box
24
26
  sx={{
@@ -73,12 +73,16 @@ export default function UserInfo({
73
73
  {...rest}
74
74
  sx={{
75
75
  display: 'flex',
76
- flexDirection: 'column',
76
+ flexDirection: {
77
+ xs: 'column',
78
+ md: 'row',
79
+ },
80
+ alignItems: 'flex-start',
77
81
  gap: 3,
78
82
  ...rest?.sx,
79
83
  }}>
80
84
  {userInfoListData.map((item) => (
81
- <UserInfoItem key={item.title} data={item} />
85
+ <UserInfoItem key={item.title} data={item} sx={{ flex: 1 }} />
82
86
  ))}
83
87
  </Paper>
84
88
  );
@@ -0,0 +1,7 @@
1
+ import axios from 'axios';
2
+
3
+ axios.defaults.timeout = 10 * 1000; // 超时时间设为10s
4
+
5
+ const api = axios.create();
6
+
7
+ export { axios, api };
@@ -23,6 +23,7 @@ export const translations = {
23
23
  noUserFound: '未找到指定的用户',
24
24
  notificationManagement: '通知管理',
25
25
  privacyManagement: '隐私管理',
26
+ storageManagement: "存储管理",
26
27
  webhook: {
27
28
  url: '自定义URL',
28
29
  slack: 'Slack',
@@ -33,6 +34,8 @@ export const translations = {
33
34
  },
34
35
  toPublic: '公开 “{name}” 页面',
35
36
  currentPassport: '当前使用的通行证',
37
+ switchProfile: '切换',
38
+ userInfo: '个人信息',
36
39
  },
37
40
  en: {
38
41
  settings: 'Settings',
@@ -55,6 +58,7 @@ export const translations = {
55
58
  emptyField: 'Empty field',
56
59
  notificationManagement: 'Notification',
57
60
  privacyManagement: 'Privacy',
61
+ storageManagement: 'Storage',
58
62
  emptyContent: 'Empty',
59
63
  underProtected: 'This page has protected privacy',
60
64
  noUserFound: 'No user found',
@@ -68,5 +72,7 @@ export const translations = {
68
72
  },
69
73
  toPublic: 'Public "{name}" page',
70
74
  currentPassport: 'Passport currently in use',
75
+ switchProfile: 'Switch',
76
+ userInfo: 'User Info',
71
77
  },
72
78
  };
@@ -0,0 +1,86 @@
1
+ import { createContext, useContext, useMemo, useState, useEffect } from 'react';
2
+ import { SessionContext as TSessionContext } from '../@types';
3
+ import { SessionContext } from '@arcblock/did-connect/lib/Session';
4
+
5
+
6
+ export interface SpaceGateway {
7
+ did: string;
8
+ name: string;
9
+ url: string;
10
+ endpoint: string;
11
+ }
12
+
13
+ export interface SettingStorageEndpoint {
14
+ (endpoint: string | undefined): void | Promise<void>;
15
+ }
16
+
17
+ interface ConfigUserSpaceContextType {
18
+ loading: boolean;
19
+ spaceGateway: SpaceGateway | undefined;
20
+ deleteSpaceGateway: (spaceGateway: SpaceGateway) => Promise<void>;
21
+ updateSpaceGateway: (updateSpaceGateway: SpaceGateway) => Promise<void>;
22
+ storageEndpoint: string;
23
+ settingStorageEndpoint: SettingStorageEndpoint;
24
+ hasStorageEndpoint: boolean;
25
+ }
26
+
27
+ const ConfigUserSpaceContext = createContext<ConfigUserSpaceContextType>({} as ConfigUserSpaceContextType);
28
+ const { Provider, Consumer } = ConfigUserSpaceContext;
29
+
30
+ function ConfigUserSpaceProvider({ children }: {children: React.ReactNode }) {
31
+ const [loading] = useState(false);
32
+ const {session} = useContext<TSessionContext>(SessionContext);
33
+ const { user } = session;
34
+
35
+ const [spaceGateway, setSpaceGateway] = useState<SpaceGateway | undefined>();
36
+ const storageEndpoint = useMemo(() => {
37
+ return user?.didSpace?.endpoint;
38
+ }, [user?.didSpace]);
39
+
40
+ useEffect(() => {
41
+ setSpaceGateway(user?.didSpace as SpaceGateway)
42
+ }, [user?.didSpace])
43
+
44
+ const deleteSpaceGateway = async (): Promise<void> => {
45
+ setSpaceGateway(undefined);
46
+ };
47
+
48
+ const updateSpaceGateway = async (x: SpaceGateway) => {
49
+ setSpaceGateway(x);
50
+ session.refresh();
51
+ // eslint-disable-next-line no-use-before-define
52
+ await settingStorageEndpoint(x.endpoint);
53
+ };
54
+
55
+
56
+ const settingStorageEndpoint = (endpoint: string | undefined) => {};
57
+
58
+ const hasStorageEndpoint = Boolean(storageEndpoint && spaceGateway);
59
+
60
+ return (
61
+ <Provider
62
+ value={{
63
+ loading,
64
+ spaceGateway,
65
+ deleteSpaceGateway,
66
+ updateSpaceGateway,
67
+ storageEndpoint,
68
+ settingStorageEndpoint,
69
+ hasStorageEndpoint,
70
+ }}>
71
+ {children}
72
+ </Provider>
73
+ );
74
+ }
75
+
76
+ function useConfigUserSpaceContext() {
77
+ const res = useContext(ConfigUserSpaceContext);
78
+ return res;
79
+ }
80
+
81
+ export {
82
+ ConfigUserSpaceContext,
83
+ ConfigUserSpaceProvider,
84
+ Consumer as ConfigUserSpaceConsumer,
85
+ useConfigUserSpaceContext,
86
+ };
@@ -0,0 +1,6 @@
1
+ import { Breakpoint, useTheme, useMediaQuery } from '@mui/material';
2
+
3
+ export default function useMobile({ key = 'sm' }: { key?: number | Breakpoint }) {
4
+ const theme = useTheme();
5
+ return useMediaQuery(theme.breakpoints.down(key));
6
+ }
@@ -0,0 +1,10 @@
1
+ import { joinURL } from "ufo";
2
+
3
+ export function getSpaceNftDisplayUrlFromEndpoint(endpoint: string): string {
4
+ const prefix = endpoint.replace(/\/api\/space\/.+/, '');
5
+
6
+ const strArray = endpoint.replace(/\/$/, '').split('/');
7
+ const spaceDid = strArray.at(-4);
8
+
9
+ return joinURL(prefix, `/api/space/nft/display?spaceDid=${spaceDid}`);
10
+ }
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- presets: [
3
- ['@babel/preset-env', { modules: false, targets: 'chrome 114' }],
4
- ['@babel/preset-react', { useBuiltIns: true, runtime: 'automatic' }],
5
- ],
6
- plugins: ['babel-plugin-inline-react-svg'],
7
- ignore: ['src/**/*.stories.js', 'src/**/demo'],
8
- };