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
149a80b7
Commit
149a80b7
authored
Sep 18, 2024
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add wallet info into profile menu
parent
c2f67dd7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
11 deletions
+109
-11
ProfileButton.tsx
ui/snippets/profile/ProfileButton.tsx
+10
-3
ProfileDesktop.tsx
ui/snippets/profile/ProfileDesktop.tsx
+2
-2
ProfileMenuContent.tsx
ui/snippets/profile/ProfileMenuContent.tsx
+7
-6
ProfileMenuWallet.tsx
ui/snippets/profile/ProfileMenuWallet.tsx
+90
-0
No files found.
ui/snippets/profile/ProfileButton.tsx
View file @
149a80b7
...
...
@@ -17,7 +17,14 @@ interface Props {
}
const
ProfileButton
=
({
profileQuery
,
size
,
variant
,
onClick
}:
Props
,
ref
:
React
.
ForwardedRef
<
HTMLDivElement
>
)
=>
{
const
{
data
,
isPending
}
=
profileQuery
;
const
[
isFetched
,
setIsFetched
]
=
React
.
useState
(
false
);
const
{
data
,
isLoading
}
=
profileQuery
;
React
.
useEffect
(()
=>
{
if
(
!
isLoading
)
{
setIsFetched
(
true
);
}
},
[
isLoading
]);
const
content
=
(()
=>
{
if
(
!
data
)
{
...
...
@@ -41,10 +48,10 @@ const ProfileButton = ({ profileQuery, size, variant, onClick }: Props, ref: Rea
label=
{
<
span
>
Sign in to My Account to add tags,
<
br
/>
create watchlists, access API keys and more
</
span
>
}
textAlign=
"center"
padding=
{
2
}
isDisabled=
{
is
Pending
||
Boolean
(
data
)
}
isDisabled=
{
is
Fetched
||
Boolean
(
data
)
}
openDelay=
{
500
}
>
<
Skeleton
isLoaded=
{
!
isPending
}
borderRadius=
"base"
ref=
{
ref
}
>
<
Skeleton
isLoaded=
{
isFetched
}
borderRadius=
"base"
ref=
{
ref
}
>
<
Button
size=
{
size
}
variant=
{
variant
}
...
...
ui/snippets/profile/ProfileDesktop.tsx
View file @
149a80b7
...
...
@@ -31,9 +31,9 @@ const ProfileDesktop = ({ buttonSize, isHomePage }: Props) => {
</
PopoverTrigger
>
{
profileQuery
.
data
&&
(
<
PopoverContent
maxW=
"
40
0px"
minW=
"220px"
w=
"min-content"
>
<
PopoverContent
maxW=
"
28
0px"
minW=
"220px"
w=
"min-content"
>
<
PopoverBody
>
<
ProfileMenuContent
data=
{
profileQuery
.
data
}
on
NavLinkClick
=
{
profileMenu
.
onClose
}
/>
<
ProfileMenuContent
data=
{
profileQuery
.
data
}
on
Close
=
{
profileMenu
.
onClose
}
/>
</
PopoverBody
>
</
PopoverContent
>
)
}
...
...
ui/snippets/profile/ProfileMenuContent.tsx
View file @
149a80b7
...
...
@@ -9,6 +9,7 @@ import { route } from 'nextjs-routes';
import
config
from
'
configs/app
'
;
import
ProfileMenuNavLink
from
'
./ProfileMenuNavLink
'
;
import
ProfileMenuWallet
from
'
./ProfileMenuWallet
'
;
import
{
getUserHandle
}
from
'
./utils
'
;
const
navLinks
:
Array
<
NavLink
>
=
[
...
...
@@ -41,10 +42,10 @@ const navLinks: Array<NavLink> = [
interface
Props
{
data
?:
UserInfo
;
on
NavLinkClick
?:
()
=>
void
;
on
Close
?:
()
=>
void
;
}
const
ProfileMenuContent
=
({
data
,
on
NavLinkClick
}:
Props
)
=>
{
const
ProfileMenuContent
=
({
data
,
on
Close
}:
Props
)
=>
{
return
(
<
Box
>
...
...
@@ -53,19 +54,19 @@ const ProfileMenuContent = ({ data, onNavLinkClick }: Props) => {
text=
"Profile"
href=
{
route
({
pathname
:
'
/auth/profile
'
})
}
icon=
"profile"
onClick=
{
on
NavLinkClick
}
onClick=
{
on
Close
}
/>
{
data
?.
email
&&
<
Text
variant=
"secondary"
fontSize=
"sm"
>
{
getUserHandle
(
data
.
email
)
}
</
Text
>
}
</
Flex
>
<
Divider
/>
<
ProfileMenuWallet
onClose=
{
onClose
}
/>
<
VStack
as=
"ul"
spacing=
"0"
alignItems=
"flex-start"
overflow=
"hidden"
>
{
navLinks
.
map
((
item
)
=>
(
<
ProfileMenuNavLink
key=
{
item
.
text
}
{
...
item
}
onClick=
{
on
NavLinkClick
}
onClick=
{
on
Close
}
/>
))
}
</
VStack
>
...
...
@@ -75,7 +76,7 @@ const ProfileMenuContent = ({ data, onNavLinkClick }: Props) => {
<
ProfileMenuNavLink
text=
"Sign out"
icon=
"sign_out"
onClick=
{
on
NavLinkClick
}
onClick=
{
on
Close
}
/>
</
Box
>
);
...
...
ui/snippets/profile/ProfileMenuWallet.tsx
0 → 100644
View file @
149a80b7
import
{
Button
,
Divider
,
Flex
,
IconButton
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
config
from
'
configs/app
'
;
import
useApiQuery
from
'
lib/api/useApiQuery
'
;
import
delay
from
'
lib/delay
'
;
import
AddressEntity
from
'
ui/shared/entities/address/AddressEntity
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
useWallet
from
'
../walletMenu/useWallet
'
;
interface
Props
{
onClose
?:
()
=>
void
;
}
const
ProfileMenuWallet
=
({
onClose
}:
Props
)
=>
{
const
wallet
=
useWallet
({
source
:
'
Header
'
});
const
addressDomainQuery
=
useApiQuery
(
'
address_domain
'
,
{
pathParams
:
{
chainId
:
config
.
chain
.
id
,
address
:
wallet
.
address
,
},
queryOptions
:
{
enabled
:
config
.
features
.
nameService
.
isEnabled
&&
Boolean
(
wallet
.
address
),
},
});
const
handleConnectWalletClick
=
React
.
useCallback
(
async
()
=>
{
wallet
.
openModal
();
await
delay
(
300
);
onClose
?.();
},
[
wallet
,
onClose
]);
const
handleOpenWalletClick
=
React
.
useCallback
(
async
()
=>
{
wallet
.
openModal
();
await
delay
(
300
);
onClose
?.();
},
[
wallet
,
onClose
]);
if
(
!
config
.
features
.
blockchainInteraction
.
isEnabled
)
{
return
<
Divider
/>;
}
if
(
wallet
.
isWalletConnected
)
{
return
(
<>
<
Divider
/>
<
Flex
alignItems=
"center"
columnGap=
{
2
}
py=
"14px"
>
<
AddressEntity
address=
{
{
hash
:
wallet
.
address
,
ens_domain_name
:
addressDomainQuery
.
data
?.
domain
?.
name
}
}
isLoading=
{
addressDomainQuery
.
isPending
}
isTooltipDisabled
truncation=
"dynamic"
fontSize=
"sm"
fontWeight=
{
700
}
/>
<
IconButton
aria
-
label=
"Open wallet"
icon=
{
<
IconSvg
name=
"gear_slim"
boxSize=
{
5
}
/>
}
variant=
"simple"
color=
"icon_info"
boxSize=
{
5
}
onClick=
{
handleOpenWalletClick
}
isLoading=
{
wallet
.
isModalOpening
}
flexShrink=
{
0
}
/>
</
Flex
>
<
Divider
/>
</>
);
}
const
isLoading
=
wallet
.
isModalOpening
||
wallet
.
isModalOpen
;
return
(
<
Button
size=
"sm"
onClick=
{
handleConnectWalletClick
}
isLoading=
{
isLoading
}
loadingText=
"Connect Wallet"
w=
"100%"
my=
{
2
}
>
Connect Wallet
</
Button
>
);
};
export
default
React
.
memo
(
ProfileMenuWallet
);
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