@blocklet/ui-react 2.9.18 → 2.9.20
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/build.config.ts +1 -1
- package/es/@types/index.d.ts +2 -0
- package/es/UserCenter/components/settings.d.ts +1 -2
- package/es/UserCenter/components/settings.js +8 -1
- package/es/UserCenter/components/storage/connect-to.d.ts +7 -0
- package/es/UserCenter/components/storage/connect-to.js +104 -0
- package/es/UserCenter/components/storage/connected.d.ts +7 -0
- package/es/UserCenter/components/storage/connected.js +21 -0
- package/es/UserCenter/components/storage/delete.d.ts +7 -0
- package/es/UserCenter/components/storage/delete.js +59 -0
- package/es/UserCenter/components/storage/disconnect.d.ts +3 -0
- package/es/UserCenter/components/storage/disconnect.js +23 -0
- package/es/UserCenter/components/storage/icons/empty-spaces-nft.svg +58 -0
- package/es/UserCenter/components/storage/icons/long-arrow.svg +5 -0
- package/es/UserCenter/components/storage/icons/space-connected.svg +3 -0
- package/es/UserCenter/components/storage/icons/space-disconnect.svg +3 -0
- package/es/UserCenter/components/storage/index.d.ts +3 -0
- package/es/UserCenter/components/storage/index.js +25 -0
- package/es/UserCenter/components/storage/item.d.ts +9 -0
- package/es/UserCenter/components/storage/item.js +147 -0
- package/es/UserCenter/components/storage/preview-nft.d.ts +6 -0
- package/es/UserCenter/components/storage/preview-nft.js +80 -0
- package/es/UserCenter/components/user-center.d.ts +2 -1
- package/es/UserCenter/components/user-center.js +8 -4
- package/es/UserCenter/libs/api.d.ts +3 -0
- package/es/UserCenter/libs/api.js +4 -0
- package/es/UserCenter/libs/locales.d.ts +2 -0
- package/es/UserCenter/libs/locales.js +2 -0
- package/es/contexts/config-user-space.d.ts +26 -0
- package/es/contexts/config-user-space.js +53 -0
- package/es/hooks/use-mobile.d.ts +4 -0
- package/es/hooks/use-mobile.js +5 -0
- package/es/libs/spaces.d.ts +1 -0
- package/es/libs/spaces.js +7 -0
- package/lib/@types/index.d.ts +2 -0
- package/lib/UserCenter/components/settings.d.ts +1 -2
- package/lib/UserCenter/components/settings.js +9 -1
- package/lib/UserCenter/components/storage/connect-to.d.ts +7 -0
- package/lib/UserCenter/components/storage/connect-to.js +127 -0
- package/lib/UserCenter/components/storage/connected.d.ts +7 -0
- package/lib/UserCenter/components/storage/connected.js +45 -0
- package/lib/UserCenter/components/storage/delete.d.ts +7 -0
- package/lib/UserCenter/components/storage/delete.js +71 -0
- package/lib/UserCenter/components/storage/disconnect.d.ts +3 -0
- package/lib/UserCenter/components/storage/disconnect.js +37 -0
- package/lib/UserCenter/components/storage/icons/empty-spaces-nft.svg +58 -0
- package/lib/UserCenter/components/storage/icons/long-arrow.svg +5 -0
- package/lib/UserCenter/components/storage/icons/space-connected.svg +3 -0
- package/lib/UserCenter/components/storage/icons/space-disconnect.svg +3 -0
- package/lib/UserCenter/components/storage/index.d.ts +3 -0
- package/lib/UserCenter/components/storage/index.js +56 -0
- package/lib/UserCenter/components/storage/item.d.ts +9 -0
- package/lib/UserCenter/components/storage/item.js +179 -0
- package/lib/UserCenter/components/storage/preview-nft.d.ts +6 -0
- package/lib/UserCenter/components/storage/preview-nft.js +88 -0
- package/lib/UserCenter/components/user-center.d.ts +2 -1
- package/lib/UserCenter/components/user-center.js +10 -6
- package/lib/UserCenter/libs/api.d.ts +3 -0
- package/lib/UserCenter/libs/api.js +16 -0
- package/lib/UserCenter/libs/locales.d.ts +2 -0
- package/lib/UserCenter/libs/locales.js +2 -0
- package/lib/contexts/config-user-space.d.ts +26 -0
- package/lib/contexts/config-user-space.js +61 -0
- package/lib/hooks/use-mobile.d.ts +4 -0
- package/lib/hooks/use-mobile.js +13 -0
- package/lib/libs/spaces.d.ts +1 -0
- package/lib/libs/spaces.js +13 -0
- package/package.json +6 -4
- package/src/@types/index.ts +3 -0
- package/src/UserCenter/components/settings.tsx +8 -2
- package/src/UserCenter/components/storage/connect-to.tsx +117 -0
- package/src/UserCenter/components/storage/connected.tsx +29 -0
- package/src/UserCenter/components/storage/delete.tsx +66 -0
- package/src/UserCenter/components/storage/disconnect.tsx +27 -0
- package/src/UserCenter/components/storage/icons/empty-spaces-nft.svg +58 -0
- package/src/UserCenter/components/storage/icons/long-arrow.svg +5 -0
- package/src/UserCenter/components/storage/icons/space-connected.svg +3 -0
- package/src/UserCenter/components/storage/icons/space-disconnect.svg +3 -0
- package/src/UserCenter/components/storage/index.tsx +47 -0
- package/src/UserCenter/components/storage/item.tsx +150 -0
- package/src/UserCenter/components/storage/preview-nft.tsx +72 -0
- package/src/UserCenter/components/user-center.tsx +10 -4
- package/src/UserCenter/libs/api.ts +7 -0
- package/src/UserCenter/libs/locales.ts +2 -0
- package/src/contexts/config-user-space.tsx +86 -0
- package/src/hooks/use-mobile.tsx +6 -0
- package/src/libs/spaces.tsx +10 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Box, BoxProps, Chip, Typography } from '@mui/material';
|
|
2
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
+
import toast from '@arcblock/ux/lib/Toast';
|
|
4
|
+
import CheckIcon from '@mui/icons-material/Check';
|
|
5
|
+
import styled from '@emotion/styled';
|
|
6
|
+
// @ts-expect-error
|
|
7
|
+
import SpacesConnectedSvg from './icons/space-connected.svg?react';
|
|
8
|
+
import DidAddress from '@arcblock/ux/lib/DID';
|
|
9
|
+
import PropTypes, { bool, func } from 'prop-types';
|
|
10
|
+
import PreviewSpaceNft from './preview-nft';
|
|
11
|
+
import { SpaceGateway } from '../../../contexts/config-user-space';
|
|
12
|
+
import useMobile from '../../../hooks/use-mobile';
|
|
13
|
+
import { getSpaceNftDisplayUrlFromEndpoint } from '../../../libs/spaces';
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
function SpaceItem({ spaceGateway, connected, onDisconnect, ...rest }: {spaceGateway: SpaceGateway, connected: boolean, onDisconnect: Function} & BoxProps) {
|
|
17
|
+
const isMobile = useMobile({});
|
|
18
|
+
const { t } = useLocaleContext();
|
|
19
|
+
|
|
20
|
+
const handleOnDisconnect = async () => {
|
|
21
|
+
try {
|
|
22
|
+
await onDisconnect();
|
|
23
|
+
toast.success(t('storage.spaces.gateway.delete.succeeded', { name: spaceGateway.name }));
|
|
24
|
+
} catch (error: any) {
|
|
25
|
+
console.error(error);
|
|
26
|
+
toast.error(error.message);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<BoxContainer
|
|
32
|
+
style={{
|
|
33
|
+
position: 'relative',
|
|
34
|
+
}}>
|
|
35
|
+
<Box
|
|
36
|
+
sx={{
|
|
37
|
+
backgroundColor: connected ? '#F0FDFF' : 'inherit',
|
|
38
|
+
'&:hover': {
|
|
39
|
+
backgroundColor: connected ? '#F0FDFF' : '#FBFBFB',
|
|
40
|
+
},
|
|
41
|
+
borderRadius: '8px',
|
|
42
|
+
}}
|
|
43
|
+
display="flex"
|
|
44
|
+
padding="12px 20px"
|
|
45
|
+
{...rest}>
|
|
46
|
+
<Box display="flex">
|
|
47
|
+
<PreviewSpaceNft alt={spaceGateway.did} src={getSpaceNftDisplayUrlFromEndpoint(spaceGateway.endpoint)} />
|
|
48
|
+
</Box>
|
|
49
|
+
<Box
|
|
50
|
+
className="spaces-info"
|
|
51
|
+
display="flex"
|
|
52
|
+
flexGrow={1}
|
|
53
|
+
flexDirection="column"
|
|
54
|
+
sx={{ marginLeft: '20px', padding: '0px 0px' }}>
|
|
55
|
+
<Box className="spaces-info" display="flex" maxWidth="360px" alignItems="center">
|
|
56
|
+
<Typography color={connected ? 'primary' : 'inherit'} fontSize="1rem" fontWeight="bold">
|
|
57
|
+
{spaceGateway.name}
|
|
58
|
+
</Typography>
|
|
59
|
+
<Chip
|
|
60
|
+
label={
|
|
61
|
+
<>
|
|
62
|
+
<SpacesConnectedSvg style={{ marginRight: '4px' }} />
|
|
63
|
+
{t('storage.spaces.connected.tag')}
|
|
64
|
+
</>
|
|
65
|
+
}
|
|
66
|
+
variant="outlined"
|
|
67
|
+
size="small"
|
|
68
|
+
style={{ marginLeft: isMobile ? undefined : '20px', fontWeight: 'bold' }}
|
|
69
|
+
/>
|
|
70
|
+
</Box>
|
|
71
|
+
<Box className="spaces-address" display="flex" color="#9397A1" marginTop="8px">
|
|
72
|
+
<Typography
|
|
73
|
+
sx={{
|
|
74
|
+
display: 'inline-flex',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
fontSize: '14px',
|
|
77
|
+
}}
|
|
78
|
+
color="#9397A1">
|
|
79
|
+
{spaceGateway.did && (
|
|
80
|
+
<DidAddress copyable={false} size={14} compact responsive={false} did={spaceGateway.did} />
|
|
81
|
+
)}
|
|
82
|
+
</Typography>
|
|
83
|
+
</Box>
|
|
84
|
+
</Box>
|
|
85
|
+
</Box>
|
|
86
|
+
|
|
87
|
+
<Box className="selected-container selected">
|
|
88
|
+
{/* check icon */}
|
|
89
|
+
<CheckIcon className="selected-icon" />
|
|
90
|
+
</Box>
|
|
91
|
+
</BoxContainer>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const BoxContainer = styled(Box)`
|
|
96
|
+
.selected-container {
|
|
97
|
+
position: absolute;
|
|
98
|
+
right: 0px;
|
|
99
|
+
bottom: 0px;
|
|
100
|
+
display: flex;
|
|
101
|
+
-webkit-box-pack: end;
|
|
102
|
+
justify-content: flex-end;
|
|
103
|
+
align-items: flex-end;
|
|
104
|
+
width: 32px;
|
|
105
|
+
height: 32px;
|
|
106
|
+
border-radius: 0px 0px 8px;
|
|
107
|
+
color: rgb(255, 255, 255);
|
|
108
|
+
overflow: hidden;
|
|
109
|
+
transition: all 0.4s ease 0s;
|
|
110
|
+
|
|
111
|
+
&::after {
|
|
112
|
+
position: absolute;
|
|
113
|
+
z-index: 0;
|
|
114
|
+
left: 60px;
|
|
115
|
+
top: 60px;
|
|
116
|
+
display: block;
|
|
117
|
+
width: 0px;
|
|
118
|
+
height: 0px;
|
|
119
|
+
border-width: 16px;
|
|
120
|
+
border-style: solid;
|
|
121
|
+
border-color: transparent #1dc1c7 #1dc1c7 transparent;
|
|
122
|
+
transition: all 0.1s ease 0s;
|
|
123
|
+
content: '';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.selected-icon {
|
|
127
|
+
visibility: hidden;
|
|
128
|
+
width: 60%;
|
|
129
|
+
height: 60%;
|
|
130
|
+
position: relative;
|
|
131
|
+
z-index: 2;
|
|
132
|
+
margin: 0px 1px 1px 0px;
|
|
133
|
+
font-size: 16px;
|
|
134
|
+
transition: all 0.2s ease 0s;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.selected-container.selected {
|
|
139
|
+
&::after {
|
|
140
|
+
left: 0px;
|
|
141
|
+
top: 0px;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.selected-icon {
|
|
145
|
+
visibility: visible;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
`;
|
|
149
|
+
|
|
150
|
+
export default SpaceItem;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import ReactPlaceholder from 'react-placeholder';
|
|
3
|
+
import { Dialog, DialogContent, IconButton } from '@mui/material';
|
|
4
|
+
import CloseOutlinedIcon from '@mui/icons-material/CloseOutlined';
|
|
5
|
+
// @ts-expect-error
|
|
6
|
+
import EmptySpacesNFT from './icons/empty-spaces-nft.svg?react';
|
|
7
|
+
|
|
8
|
+
function PreviewSpaceNft({ src, alt }: {src: string, alt: string}) {
|
|
9
|
+
const [showEmptySpaceNFT, setShowEmptySpaceNFT] = useState(false);
|
|
10
|
+
const [open, setOpen] = useState(false);
|
|
11
|
+
|
|
12
|
+
const handleOpen = () => setOpen(true);
|
|
13
|
+
const handleClose = () => setOpen(false);
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<ReactPlaceholder
|
|
18
|
+
ready={showEmptySpaceNFT}
|
|
19
|
+
customPlaceholder={
|
|
20
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
21
|
+
<img
|
|
22
|
+
style={{ cursor: 'pointer' }}
|
|
23
|
+
alt={alt}
|
|
24
|
+
src={src}
|
|
25
|
+
width="58px"
|
|
26
|
+
height="58px"
|
|
27
|
+
onError={() => setShowEmptySpaceNFT(true)}
|
|
28
|
+
onClick={handleOpen}
|
|
29
|
+
/>
|
|
30
|
+
}>
|
|
31
|
+
<EmptySpacesNFT style={{ cursor: 'pointer', width: '58px', height: '58px' }} onClick={handleOpen} />
|
|
32
|
+
</ReactPlaceholder>
|
|
33
|
+
<Dialog
|
|
34
|
+
open={open}
|
|
35
|
+
onClose={handleClose}
|
|
36
|
+
aria-labelledby="preview-space-nft-display"
|
|
37
|
+
aria-describedby="preview space nft display"
|
|
38
|
+
fullWidth
|
|
39
|
+
maxWidth="md">
|
|
40
|
+
<DialogContent style={{ padding: '8px 8px', backgroundColor: 'rgba(0,0,0,0.8)' }}>
|
|
41
|
+
<IconButton
|
|
42
|
+
color="inherit"
|
|
43
|
+
onClick={handleClose}
|
|
44
|
+
aria-label="close"
|
|
45
|
+
style={{ position: 'absolute', top: 8, right: 8, color: 'white' }}>
|
|
46
|
+
<CloseOutlinedIcon />
|
|
47
|
+
</IconButton>
|
|
48
|
+
{showEmptySpaceNFT ? (
|
|
49
|
+
<EmptySpacesNFT
|
|
50
|
+
style={{
|
|
51
|
+
width: '100%',
|
|
52
|
+
height: '75vh',
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
) : (
|
|
56
|
+
<img
|
|
57
|
+
src={src}
|
|
58
|
+
alt=""
|
|
59
|
+
style={{
|
|
60
|
+
width: '100%',
|
|
61
|
+
height: '75vh',
|
|
62
|
+
objectFit: 'contain',
|
|
63
|
+
}}
|
|
64
|
+
/>
|
|
65
|
+
)}
|
|
66
|
+
</DialogContent>
|
|
67
|
+
</Dialog>
|
|
68
|
+
</>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default PreviewSpaceNft;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
|
-
import { Box, CircularProgress,
|
|
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
5
|
|
|
@@ -36,6 +36,7 @@ export default function UserCenter({
|
|
|
36
36
|
hideFooter = false,
|
|
37
37
|
headerProps = {},
|
|
38
38
|
footerProps = {},
|
|
39
|
+
userDid,
|
|
39
40
|
}: {
|
|
40
41
|
readonly children: any;
|
|
41
42
|
readonly currentTab: string;
|
|
@@ -45,6 +46,7 @@ export default function UserCenter({
|
|
|
45
46
|
readonly hideFooter?: boolean;
|
|
46
47
|
readonly headerProps?: object;
|
|
47
48
|
readonly footerProps?: object;
|
|
49
|
+
readonly userDid?: string;
|
|
48
50
|
}) {
|
|
49
51
|
const { locale } = useLocaleContext();
|
|
50
52
|
const t = useMemoizedFn((key, data = {}) => {
|
|
@@ -54,6 +56,10 @@ export default function UserCenter({
|
|
|
54
56
|
const session = sessionCtx?.session;
|
|
55
57
|
|
|
56
58
|
const currentDid = useCreation(() => {
|
|
59
|
+
if (userDid) {
|
|
60
|
+
return userDid;
|
|
61
|
+
}
|
|
62
|
+
|
|
57
63
|
const currentUrl = window.location.href;
|
|
58
64
|
const query = getQuery(currentUrl);
|
|
59
65
|
if (query?.did) {
|
|
@@ -63,7 +69,7 @@ export default function UserCenter({
|
|
|
63
69
|
return query.did;
|
|
64
70
|
}
|
|
65
71
|
return session?.user?.did;
|
|
66
|
-
}, [session?.user?.did]);
|
|
72
|
+
}, [session?.user?.did, userDid]);
|
|
67
73
|
|
|
68
74
|
const isMyself = useCreation(() => {
|
|
69
75
|
if (session?.user) {
|
|
@@ -284,13 +290,13 @@ export default function UserCenter({
|
|
|
284
290
|
{isMyself ? (
|
|
285
291
|
<>
|
|
286
292
|
<Box>
|
|
287
|
-
<Typography variant="
|
|
293
|
+
<Typography variant="h6" sx={{ fontWeight: 600, mb: 1.5 }}>
|
|
288
294
|
{t('passport')}
|
|
289
295
|
</Typography>
|
|
290
296
|
<Passport user={userState.data} />
|
|
291
297
|
</Box>
|
|
292
298
|
<Box>
|
|
293
|
-
<Typography variant="
|
|
299
|
+
<Typography variant="h6" sx={{ fontWeight: 600, mb: 1.5 }}>
|
|
294
300
|
{t('userInfo')}
|
|
295
301
|
</Typography>
|
|
296
302
|
<UserInfo
|
|
@@ -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',
|
|
@@ -57,6 +58,7 @@ export const translations = {
|
|
|
57
58
|
emptyField: 'Empty field',
|
|
58
59
|
notificationManagement: 'Notification',
|
|
59
60
|
privacyManagement: 'Privacy',
|
|
61
|
+
storageManagement: 'Storage',
|
|
60
62
|
emptyContent: 'Empty',
|
|
61
63
|
underProtected: 'This page has protected privacy',
|
|
62
64
|
noUserFound: 'No user found',
|
|
@@ -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,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
|
+
}
|