-
Notifications
You must be signed in to change notification settings - Fork 0
feat: update account page to display faucet, activity and iexec account #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
927d036
0e05a81
cacfaef
d6adb2a
e46490a
3613389
a52c43d
d148880
f5520d0
4d729bb
e39964f
17c9c0b
7e86950
572449e
16a202a
b592af0
8e2cd30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,13 +1,23 @@ | ||||||
| import { LogOut } from 'lucide-react'; | ||||||
| import { cn } from '@/lib/utils.ts'; | ||||||
| import { ArrowDown, LogOut } from 'lucide-react'; | ||||||
| import { useState } from 'react'; | ||||||
| import { useLoginLogout } from '@/hooks/useLoginLogout'; | ||||||
| import useUserStore from '@/stores/useUser.store'; | ||||||
| import { getAvatarVisualNumber } from '@/utils/getAvatarVisualNumber.ts'; | ||||||
| import { truncateAddress } from '@/utils/truncateAddress.ts'; | ||||||
| import iExecLogo from '../../assets/iexec-logo.svg'; | ||||||
| import { ChainLink } from '../ChainLink.tsx'; | ||||||
| import { ModeToggle } from '../ModeToggle.tsx'; | ||||||
| import { Button } from '../ui/button.tsx'; | ||||||
| import { | ||||||
| DropdownMenu, | ||||||
| DropdownMenuContent, | ||||||
| DropdownMenuItem, | ||||||
| DropdownMenuTrigger, | ||||||
| } from '../ui/dropdown-menu.tsx'; | ||||||
| import { AddressChip } from './AddressChip.tsx'; | ||||||
| import { ChainSelector } from './ChainSelector.tsx'; | ||||||
| import avatarStyles from './profile.module.css'; | ||||||
|
|
||||||
| export function Navbar() { | ||||||
| const { isConnected, address: userAddress } = useUserStore(); | ||||||
|
|
@@ -17,6 +27,10 @@ export function Navbar() { | |||||
| setMenuOpen((prevState) => !prevState); | ||||||
| }; | ||||||
|
|
||||||
| const avatarVisualBg = getAvatarVisualNumber({ | ||||||
| address: userAddress!, | ||||||
| }); | ||||||
|
|
||||||
| return ( | ||||||
| <nav className="flex items-center justify-between py-6"> | ||||||
| <ChainLink to="/" className="-m-2 flex items-center gap-2 p-2 font-mono"> | ||||||
|
|
@@ -25,36 +39,51 @@ export function Navbar() { | |||||
| </ChainLink> | ||||||
| <div className="mr-8 flex items-center gap-4 md:mr-0"> | ||||||
| <Button variant="link" asChild className="text-foreground -mr-4"> | ||||||
| <ChainLink to="/faucet">Faucet</ChainLink> | ||||||
| <ChainLink to="/account?accountTab=Faucet">Faucet</ChainLink> | ||||||
| </Button> | ||||||
| {isConnected && ( | ||||||
| <div className="-mr-4 hidden md:flex"> | ||||||
| <Button variant="link" asChild className="text-foreground"> | ||||||
| <ChainLink to={`/address/${userAddress}?from=my_activity`}> | ||||||
| My activity | ||||||
| </ChainLink> | ||||||
| </Button> | ||||||
| <Button variant="link" asChild className="text-foreground"> | ||||||
| <ChainLink to="/account">iExec Account</ChainLink> | ||||||
| </Button> | ||||||
| </div> | ||||||
| )} | ||||||
| <span className="border-secondary h-9 border-l" /> | ||||||
| <div className="content hidden gap-4 md:flex"> | ||||||
| <ModeToggle /> | ||||||
| <ChainSelector /> | ||||||
| </div> | ||||||
| {isConnected ? ( | ||||||
| <div className="flex max-w-[1260px] items-center gap-2"> | ||||||
| <AddressChip address={userAddress!} /> | ||||||
|
|
||||||
| <button | ||||||
| type="button" | ||||||
| className="hover:drop-shadow-link-hover p-1" | ||||||
| onClick={() => logout()} | ||||||
| > | ||||||
| <LogOut size="20" /> | ||||||
| </button> | ||||||
| <DropdownMenu> | ||||||
| <DropdownMenuTrigger className="text-primary bg-popover flex items-center gap-2 rounded-lg px-2 py-2"> | ||||||
| <div | ||||||
| className={cn( | ||||||
| avatarStyles[avatarVisualBg], | ||||||
| 'bg-background relative z-10 size-4 rounded-full bg-cover' | ||||||
| )} | ||||||
| /> | ||||||
| <span className="text-sm"> | ||||||
| {truncateAddress(userAddress!, { startLen: 5, endLen: 3 })} | ||||||
| </span> | ||||||
| <ArrowDown className="text-foreground" size={16} /> | ||||||
| </DropdownMenuTrigger> | ||||||
| <DropdownMenuContent> | ||||||
| <DropdownMenuItem> | ||||||
| <ChainLink to="/account?accountTab=Wallet+Activity"> | ||||||
| Wallet Activity | ||||||
| </ChainLink> | ||||||
| </DropdownMenuItem> | ||||||
| <DropdownMenuItem> | ||||||
| <ChainLink to="/account?accountTab=Manage+iExec+Account"> | ||||||
|
||||||
| <ChainLink to="/account?accountTab=Manage+iExec+Account"> | |
| <ChainLink to="/account?accountTab=Account"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The truncateAddress is called with explicit options
{ startLen: 5, endLen: 3 }, but these values aren't part of the predefined union type in the updated truncateAddress function signature. While the function now acceptsnumberas a type (line 4-5 of truncateAddress.ts), this creates inconsistency. Consider using the predefined values or documenting why custom values are needed here.