Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
ee71acd8
Commit
ee71acd8
authored
Sep 20, 2024
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
link wallet from profile
parent
1970de13
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
14 deletions
+40
-14
MyProfileWallet.tsx
ui/myProfile/MyProfileWallet.tsx
+15
-3
MyProfile.tsx
ui/pages/MyProfile.tsx
+19
-5
AuthModal.tsx
ui/snippets/auth/AuthModal.tsx
+3
-3
AuthModalScreenConnectWallet.tsx
ui/snippets/auth/screens/AuthModalScreenConnectWallet.tsx
+3
-3
No files found.
ui/myProfile/MyProfileWallet.tsx
View file @
ee71acd8
import
{
B
utton
,
Heading
}
from
'
@chakra-ui/react
'
;
import
{
B
ox
,
Button
,
Heading
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
type
{
UseQueryResult
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
type
{
UserInfo
}
from
'
types/api/account
'
;
import
AddressEntity
from
'
ui/shared/entities/address/AddressEntity
'
;
interface
Props
{
profileQuery
:
UseQueryResult
<
UserInfo
,
unknown
>
;
onAddWallet
:
()
=>
void
;
}
const
MyProfileWallet
=
({
profileQuery
}:
Props
)
=>
{
const
MyProfileWallet
=
({
profileQuery
,
onAddWallet
}:
Props
)
=>
{
const
bgColor
=
useColorModeValue
(
'
blackAlpha.50
'
,
'
whiteAlpha.50
'
);
return
(
<
section
>
<
Heading
as=
"h2"
size=
"sm"
mb=
{
3
}
>
My linked wallet
</
Heading
>
{
!
profileQuery
.
data
?.
address_hash
&&
<
Button
size=
"sm"
>
Link wallet
</
Button
>
}
{
profileQuery
.
data
?.
address_hash
?
(
<
Box
px=
{
3
}
py=
"18px"
bgColor=
{
bgColor
}
borderRadius=
"base"
>
<
AddressEntity
address=
{
{
hash
:
profileQuery
.
data
.
address_hash
}
}
fontWeight=
"500"
/>
</
Box
>
)
:
<
Button
size=
"sm"
onClick=
{
onAddWallet
}
>
Link wallet
</
Button
>
}
</
section
>
);
};
...
...
ui/pages/MyProfile.tsx
View file @
ee71acd8
import
{
Flex
}
from
'
@chakra-ui/react
'
;
import
{
Flex
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
type
{
Screen
}
from
'
ui/snippets/auth/types
'
;
import
config
from
'
configs/app
'
;
import
useFetchProfileInfo
from
'
lib/hooks/useFetchProfileInfo
'
;
import
useRedirectForInvalidAuthToken
from
'
lib/hooks/useRedirectForInvalidAuthToken
'
;
...
...
@@ -9,11 +11,20 @@ import MyProfileWallet from 'ui/myProfile/MyProfileWallet';
import
ContentLoader
from
'
ui/shared/ContentLoader
'
;
import
DataFetchAlert
from
'
ui/shared/DataFetchAlert
'
;
import
PageTitle
from
'
ui/shared/Page/PageTitle
'
;
import
AuthModal
from
'
ui/snippets/auth/AuthModal
'
;
const
MyProfile
=
()
=>
{
const
[
authInitialScreen
,
setAuthInitialScreen
]
=
React
.
useState
<
Screen
>
();
const
authModal
=
useDisclosure
();
const
profileQuery
=
useFetchProfileInfo
();
useRedirectForInvalidAuthToken
();
const
handleAddWalletClick
=
React
.
useCallback
(()
=>
{
setAuthInitialScreen
({
type
:
'
connect_wallet
'
,
isAuth
:
true
});
authModal
.
onOpen
();
},
[
authModal
]);
const
content
=
(()
=>
{
if
(
profileQuery
.
isPending
)
{
return
<
ContentLoader
/>;
...
...
@@ -24,10 +35,13 @@ const MyProfile = () => {
}
return
(
<
Flex
maxW=
"480px"
mt=
{
8
}
flexDir=
"column"
rowGap=
{
12
}
>
<
MyProfileEmail
profileQuery=
{
profileQuery
}
/>
{
config
.
features
.
blockchainInteraction
.
isEnabled
&&
<
MyProfileWallet
profileQuery=
{
profileQuery
}
/>
}
</
Flex
>
<>
<
Flex
maxW=
"480px"
mt=
{
8
}
flexDir=
"column"
rowGap=
{
12
}
>
<
MyProfileEmail
profileQuery=
{
profileQuery
}
/>
{
config
.
features
.
blockchainInteraction
.
isEnabled
&&
<
MyProfileWallet
profileQuery=
{
profileQuery
}
onAddWallet=
{
handleAddWalletClick
}
/>
}
</
Flex
>
{
authModal
.
isOpen
&&
authInitialScreen
&&
<
AuthModal
initialScreen=
{
authInitialScreen
}
onClose=
{
authModal
.
onClose
}
/>
}
</>
);
})();
...
...
ui/snippets/auth/AuthModal.tsx
View file @
ee71acd8
...
...
@@ -30,9 +30,9 @@ const AuthModal = ({ initialScreen, onClose }: Props) => {
setSteps
((
prev
)
=>
prev
.
length
>
1
?
prev
.
slice
(
0
,
-
1
)
:
prev
);
},
[]);
const
onReset
=
React
.
useCallback
(()
=>
{
setSteps
([
initialScreen
]);
},
[
initialScreen
]);
const
onReset
=
React
.
useCallback
((
isAuth
?:
boolean
)
=>
{
isAuth
?
onClose
()
:
setSteps
([
initialScreen
]);
},
[
initialScreen
,
onClose
]);
const
onAuthSuccess
=
React
.
useCallback
(
async
(
screen
:
ScreenSuccess
)
=>
{
const
{
data
}
=
await
profileQuery
.
refetch
();
...
...
ui/snippets/auth/screens/AuthModalScreenConnectWallet.tsx
View file @
ee71acd8
...
...
@@ -7,7 +7,7 @@ import useSignInWithWallet from '../useSignInWithWallet';
interface
Props
{
onSuccess
:
(
screen
:
ScreenSuccess
)
=>
void
;
onError
:
()
=>
void
;
onError
:
(
isAuth
?:
boolean
)
=>
void
;
isAuth
?:
boolean
;
}
...
...
@@ -19,8 +19,8 @@ const AuthModalScreenConnectWallet = ({ onSuccess, onError, isAuth }: Props) =>
},
[
onSuccess
,
isAuth
]);
const
handleSignInError
=
React
.
useCallback
(()
=>
{
onError
();
},
[
onError
]);
onError
(
isAuth
);
},
[
onError
,
isAuth
]);
const
{
start
}
=
useSignInWithWallet
({
onSuccess
:
handleSignInSuccess
,
onError
:
handleSignInError
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment