1
1
import {
2
- BadgeCheck ,
3
- Bell ,
4
- ChevronsUpDown ,
5
- CreditCard ,
6
- LogOut ,
7
- } from "lucide-react"
2
+ BadgeCheck ,
3
+ Bell ,
4
+ ChevronsUpDown ,
5
+ CreditCard ,
6
+ LogOut ,
7
+ } from "lucide-react" ;
8
8
9
9
import {
10
- Avatar ,
11
- AvatarFallback ,
12
- AvatarImage ,
13
- } from "@realms-world/ui/components/ui/avatar"
10
+ Avatar ,
11
+ AvatarFallback ,
12
+ AvatarImage ,
13
+ } from "@realms-world/ui/components/ui/avatar" ;
14
14
import {
15
- DropdownMenu ,
16
- DropdownMenuContent ,
17
- DropdownMenuGroup ,
18
- DropdownMenuItem ,
19
- DropdownMenuLabel ,
20
- DropdownMenuSeparator ,
21
- DropdownMenuTrigger ,
22
- } from "@realms-world/ui/components/ui/dropdown-menu"
23
- import { useAccount } from "@starknet-react/core"
24
- import { shortenHex } from "@/utils/utils"
25
- import { StarknetLoginButton } from "@/app/_components/wallet/StarknetLoginButton"
15
+ DropdownMenu ,
16
+ DropdownMenuContent ,
17
+ DropdownMenuGroup ,
18
+ DropdownMenuItem ,
19
+ DropdownMenuLabel ,
20
+ DropdownMenuSeparator ,
21
+ DropdownMenuTrigger ,
22
+ } from "@realms-world/ui/components/ui/dropdown-menu" ;
23
+ import { useAccount , useDisconnect } from "@starknet-react/core" ;
24
+ import { shortenHex } from "@/utils/utils" ;
25
+ import { StarknetLoginButton } from "@/app/_components/wallet/StarknetLoginButton" ;
26
26
27
27
export function NavUser ( {
28
- user,
28
+ user,
29
29
} : {
30
- user ?: {
31
- name : string
32
- email : string
33
- avatar : string
34
- }
30
+ user ?: {
31
+ name : string ;
32
+ email : string ;
33
+ avatar : string ;
34
+ } ;
35
35
} ) {
36
- const { address } = useAccount ( ) ;
36
+ const { address } = useAccount ( ) ;
37
+ const { disconnect } = useDisconnect ( ) ;
37
38
38
- return (
39
- < >
40
-
41
- < DropdownMenu >
42
- < DropdownMenuTrigger className = "w-full rounded-md outline-none ring-ring hover:bg-accent focus-visible:ring-2 data-[state=open]:bg-accent" >
43
- < div className = "flex items-center gap-2 px-2 py-1.5 text-left text-sm transition-all" >
44
- < Avatar className = "h-7 w-7 rounded-md border" >
45
- < AvatarImage
46
- src = { user ?. avatar }
47
- alt = { user ?. name }
48
- className = "animate-in fade-in-50 zoom-in-90"
49
- />
50
- < AvatarFallback className = "rounded-md" > CN</ AvatarFallback >
51
- </ Avatar >
52
- < div className = "grid flex-1 leading-none" >
53
- < div className = "font-medium" > { user ?. name } </ div >
54
- < div className = "overflow-hidden text-lg text-muted-foreground" >
55
- < div className = "line-clamp-1" > { address && shortenHex ( address , 8 ) } </ div >
56
- </ div >
57
- </ div >
58
- < ChevronsUpDown className = "ml-auto mr-0.5 h-4 w-4 text-muted-foreground/50" />
59
- </ div >
60
- </ DropdownMenuTrigger >
61
- < DropdownMenuContent
62
- className = "w-56"
63
- align = "end"
64
- side = "right"
65
- sideOffset = { 4 }
66
- >
67
- < DropdownMenuLabel className = "p-0 font-normal" >
68
- < div className = "flex items-center gap-2 px-1 py-1.5 text-left text-sm transition-all" >
69
- < Avatar className = "h-7 w-7 rounded-md" >
70
- < AvatarImage src = { user ?. avatar } alt = { user ?. name } />
71
- < AvatarFallback > CN</ AvatarFallback >
72
- </ Avatar >
73
- < div className = "grid flex-1" >
74
- < div className = "font-medium" > { user ?. name } </ div >
75
- < div className = "overflow-hidden text-xs text-muted-foreground" >
76
- < div className = "line-clamp-1" > { user ?. email } </ div >
77
- </ div >
78
- </ div >
79
- </ div >
80
- </ DropdownMenuLabel >
81
- < DropdownMenuSeparator />
39
+ return (
40
+ < >
41
+ < DropdownMenu >
42
+ < DropdownMenuTrigger className = "w-full rounded-md outline-none ring-ring hover:bg-accent focus-visible:ring-2 data-[state=open]:bg-accent" >
43
+ < div className = "flex items-center gap-2 px-2 py-1.5 text-left text-sm transition-all" >
44
+ < Avatar className = "h-7 w-7 rounded-md border" >
45
+ < AvatarImage
46
+ src = { user ?. avatar }
47
+ alt = { user ?. name }
48
+ className = "animate-in fade-in-50 zoom-in-90"
49
+ />
50
+ < AvatarFallback className = "rounded-md" > CN</ AvatarFallback >
51
+ </ Avatar >
52
+ < div className = "grid flex-1 leading-none" >
53
+ < div className = "font-medium" > { user ?. name } </ div >
54
+ < div className = "overflow-hidden text-lg text-muted-foreground" >
55
+ < div className = "line-clamp-1" >
56
+ { address && shortenHex ( address , 8 ) }
57
+ </ div >
58
+ </ div >
59
+ </ div >
60
+ < ChevronsUpDown className = "ml-auto mr-0.5 h-4 w-4 text-muted-foreground/50" />
61
+ </ div >
62
+ </ DropdownMenuTrigger >
63
+ < DropdownMenuContent
64
+ className = "w-56"
65
+ align = "end"
66
+ side = "right"
67
+ sideOffset = { 4 }
68
+ >
69
+ < DropdownMenuLabel className = "p-0 font-normal" >
70
+ < div className = "flex items-center gap-2 px-1 py-1.5 text-left text-sm transition-all" >
71
+ < Avatar className = "h-7 w-7 rounded-md" >
72
+ < AvatarImage src = { user ?. avatar } alt = { address } />
73
+ < AvatarFallback > CN</ AvatarFallback >
74
+ </ Avatar >
75
+ < div className = "grid flex-1" >
76
+ < div className = "font-medium" >
77
+ { address && shortenHex ( address , 8 ) }
78
+ </ div >
79
+ < div className = "overflow-hidden text-xs text-muted-foreground" >
80
+ < div className = "line-clamp-1" > { user ?. email } </ div >
81
+ </ div >
82
+ </ div >
83
+ </ div >
84
+ </ DropdownMenuLabel >
85
+ { /*<DropdownMenuSeparator />
82
86
<DropdownMenuGroup>
83
87
<DropdownMenuItem className="gap-2">
84
88
<BadgeCheck className="h-4 w-4 text-muted-foreground" />
@@ -92,14 +96,14 @@ export function NavUser({
92
96
<Bell className="h-4 w-4 text-muted-foreground" />
93
97
Notifications
94
98
</DropdownMenuItem>
95
- </ DropdownMenuGroup >
96
- < DropdownMenuSeparator />
97
- < DropdownMenuItem className = "gap-2" >
98
- < LogOut className = "h-4 w-4 text-muted-foreground" />
99
- Log out
100
- </ DropdownMenuItem >
101
- </ DropdownMenuContent >
102
- </ DropdownMenu >
103
- </ >
104
- )
99
+ </DropdownMenuGroup>*/ }
100
+ < DropdownMenuSeparator />
101
+ < DropdownMenuItem onClick = { disconnect } className = "gap-2" >
102
+ < LogOut className = "h-4 w-4 text-muted-foreground" />
103
+ Log out
104
+ </ DropdownMenuItem >
105
+ </ DropdownMenuContent >
106
+ </ DropdownMenu >
107
+ </ >
108
+ ) ;
105
109
}
0 commit comments