@@ -2,7 +2,6 @@ import { useEffect, useState } from 'react';
22import { useAccount , useDisconnect , useSwitchChain , useChainId } from 'wagmi' ;
33import LedgerConnectDialog from '@/components/LedgerConnectDialog' ;
44
5- type TokenSymbol = string ;
65import { EllipsisVertical , Wallet } from 'lucide-react' ;
76import {
87 DropdownMenu ,
@@ -19,7 +18,7 @@ import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
1918
2019interface Account {
2120 address : string ;
22- balance : Record < TokenSymbol , string > | null ;
21+ balance : Record < string , string > | null ;
2322 ens : { name : string | undefined ; avatar : string | undefined } ;
2423}
2524
@@ -44,84 +43,86 @@ export default function WalletSidebarItem({ className }: { className?: string })
4443 } , [ address ] ) ;
4544
4645 return (
47- < DropdownMenu >
48- < DropdownMenuTrigger asChild >
49- { address && account ? (
50- < SidebarMenuButton className = 'h-12' >
51- < Avatar className = 'rounded-lg' >
52- < AvatarImage src = 'https://github.com/evilrabbit.png' alt = '@evilrabbit' />
53- < AvatarFallback > ER</ AvatarFallback >
54- </ Avatar >
55- < div >
56- < p className = 'text-sm font-medium' >
57- { account . ens ?. name || `${ address . slice ( 0 , 6 ) } ...${ address . slice ( - 4 ) } ` }
58- </ p >
59- < p className = 'text-xs text-muted-foreground' > Login from · { connector ?. name } </ p >
60- </ div >
61- < EllipsisVertical className = 'ml-auto' />
62- </ SidebarMenuButton >
63- ) : (
64- < SidebarMenuButton
65- className = 'h-10 bg-primary text-primary-foreground hover:bg-primary/80 hover:text-primary-foreground flex items-center justify-center'
66- onClick = { ( ) => setDialogOpen ( true ) }
67- >
68- < Wallet /> Connect Wallet
69- </ SidebarMenuButton >
70- ) }
71- </ DropdownMenuTrigger >
72-
73- { address && account && (
74- < DropdownMenuContent side = 'right' className = 'w-[var(--radix-popper-anchor-width)] mb-2' >
75- < DropdownMenuItem >
76- < Avatar className = 'rounded-lg' >
77- < AvatarImage src = 'https://github.com/evilrabbit.png' alt = '@evilrabbit' />
78- < AvatarFallback > ER</ AvatarFallback >
79- </ Avatar >
80- < div >
81- < p className = 'text-sm font-medium' >
82- { account . ens ?. name || `${ address . slice ( 0 , 6 ) } ...${ address . slice ( - 4 ) } ` }
83- </ p >
84- < p className = 'text-xs text-muted-foreground' > Login from · { connector ?. name } </ p >
85- </ div >
86- </ DropdownMenuItem >
87- < DropdownMenuSeparator />
88- { chains && chains . length > 0 && (
89- < >
90- < DropdownMenuSub >
91- < DropdownMenuSubTrigger > Switch Network</ DropdownMenuSubTrigger >
92- < DropdownMenuSubContent className = 'max-h-72 overflow-y-auto' >
93- { chains . map ( ( chain ) => {
94- const isActive = chainId === chain . id ;
95- return (
96- < DropdownMenuItem
97- key = { chain . id }
98- disabled = { isActive }
99- onClick = { ( ) => switchChain ( { chainId : chain . id } ) }
100- >
101- < span className = 'flex-1' > { chain . label ?? `Chain ${ chain . id } ` } </ span >
102- { isActive ? < span className = 'text-xs text-muted-foreground' > Current</ span > : null }
103- </ DropdownMenuItem >
104- ) ;
105- } ) }
106- </ DropdownMenuSubContent >
107- </ DropdownMenuSub >
108- < DropdownMenuSeparator />
109- </ >
46+ < >
47+ < DropdownMenu >
48+ < DropdownMenuTrigger asChild >
49+ { address && account ? (
50+ < SidebarMenuButton className = 'h-12' >
51+ < Avatar className = 'rounded-lg' >
52+ < AvatarImage src = 'https://github.com/evilrabbit.png' alt = '@evilrabbit' />
53+ < AvatarFallback > ER</ AvatarFallback >
54+ </ Avatar >
55+ < div >
56+ < p className = 'text-sm font-medium' >
57+ { account . ens ?. name || `${ address . slice ( 0 , 6 ) } ...${ address . slice ( - 4 ) } ` }
58+ </ p >
59+ < p className = 'text-xs text-muted-foreground' > Login from · { connector ?. name } </ p >
60+ </ div >
61+ < EllipsisVertical className = 'ml-auto' />
62+ </ SidebarMenuButton >
63+ ) : (
64+ < SidebarMenuButton
65+ className = 'h-10 bg-primary text-primary-foreground hover:bg-primary/80 hover:text-primary-foreground flex items-center justify-center'
66+ onClick = { ( ) => setDialogOpen ( true ) }
67+ >
68+ < Wallet /> Connect Wallet
69+ </ SidebarMenuButton >
11070 ) }
111- < DropdownMenuItem >
112- < span > Account</ span >
113- </ DropdownMenuItem >
114- < DropdownMenuItem >
115- < span > Billing</ span >
116- </ DropdownMenuItem >
117- < DropdownMenuSeparator />
71+ </ DropdownMenuTrigger >
11872
119- < DropdownMenuItem onClick = { ( ) => disconnect ( ) } >
120- < span > Disconnect</ span >
121- </ DropdownMenuItem >
122- </ DropdownMenuContent >
123- ) }
124- </ DropdownMenu >
125- < LedgerConnectDialog open = { dialogOpen} onOpenChange = { setDialogOpen} / >
73+ { address && account && (
74+ < DropdownMenuContent side = 'right' className = 'w-[var(--radix-popper-anchor-width)] mb-2' >
75+ < DropdownMenuItem >
76+ < Avatar className = 'rounded-lg' >
77+ < AvatarImage src = 'https://github.com/evilrabbit.png' alt = '@evilrabbit' />
78+ < AvatarFallback > ER</ AvatarFallback >
79+ </ Avatar >
80+ < div >
81+ < p className = 'text-sm font-medium' >
82+ { account . ens ?. name || `${ address . slice ( 0 , 6 ) } ...${ address . slice ( - 4 ) } ` }
83+ </ p >
84+ < p className = 'text-xs text-muted-foreground' > Login from · { connector ?. name } </ p >
85+ </ div >
86+ </ DropdownMenuItem >
87+ < DropdownMenuSeparator />
88+ { chains && chains . length > 0 && (
89+ < >
90+ < DropdownMenuSub >
91+ < DropdownMenuSubTrigger > Switch Network</ DropdownMenuSubTrigger >
92+ < DropdownMenuSubContent className = 'max-h-72 overflow-y-auto' >
93+ { chains . map ( ( chain ) => {
94+ const isActive = chainId === chain . id ;
95+ return (
96+ < DropdownMenuItem
97+ key = { chain . id }
98+ disabled = { isActive }
99+ onClick = { ( ) => switchChain ( { chainId : chain . id } ) }
100+ >
101+ < span className = 'flex-1' > { chain . name } </ span >
102+ { isActive ? < span className = 'text-xs text-muted-foreground' > Current</ span > : null }
103+ </ DropdownMenuItem >
104+ ) ;
105+ } ) }
106+ </ DropdownMenuSubContent >
107+ </ DropdownMenuSub >
108+ < DropdownMenuSeparator />
109+ </ >
110+ ) }
111+ < DropdownMenuItem >
112+ < span > Account</ span >
113+ </ DropdownMenuItem >
114+ < DropdownMenuItem >
115+ < span > Billing</ span >
116+ </ DropdownMenuItem >
117+ < DropdownMenuSeparator />
118+
119+ < DropdownMenuItem onClick = { ( ) => disconnect ( ) } >
120+ < span > Disconnect</ span >
121+ </ DropdownMenuItem >
122+ </ DropdownMenuContent >
123+ ) }
124+ </ DropdownMenu >
125+ < LedgerConnectDialog open = { dialogOpen } onOpenChange = { setDialogOpen } />
126+ </ >
126127 ) ;
127128}
0 commit comments