Skip to content

Commit 019656c

Browse files
committed
feat: get user info from session
1 parent 853264f commit 019656c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/components/dashboard/navbar/user-dropdown.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,30 @@ import {
1313
DropdownMenuTrigger,
1414
} from "@/components/ui/dropdown-menu";
1515
import { signOut } from "next-auth/react";
16+
import { useSession } from "next-auth/react";
1617

1718
export function UserDropdown() {
19+
const { data } = useSession();
20+
const name = data?.user.name;
21+
const email = data?.user.email;
22+
const image = data?.user.image;
23+
1824
return (
1925
<DropdownMenu>
2026
<DropdownMenuTrigger asChild>
2127
<Button variant="ghost" className="relative h-8 w-8 rounded-full">
2228
<Avatar className="h-9 w-9">
23-
<AvatarImage
24-
src="https://randomuser.me/api/portraits/women/0.jpg"
25-
alt="avatar"
26-
/>
29+
<AvatarImage src={image ?? ""} alt="avatar" />
2730
<AvatarFallback>SC</AvatarFallback>
2831
</Avatar>
2932
</Button>
3033
</DropdownMenuTrigger>
3134
<DropdownMenuContent className="w-56" align="end" forceMount>
3235
<DropdownMenuLabel className="font-normal">
3336
<div className="flex flex-col space-y-1">
34-
<p className="text-sm font-medium leading-none">shadcn</p>
37+
<p className="text-sm font-medium leading-none">{name}</p>
3538
<p className="text-xs leading-none text-muted-foreground">
36-
m@example.com
39+
{email}
3740
</p>
3841
</div>
3942
</DropdownMenuLabel>
@@ -51,7 +54,6 @@ export function UserDropdown() {
5154
Settings
5255
<DropdownMenuShortcut>⌘S</DropdownMenuShortcut>
5356
</DropdownMenuItem>
54-
<DropdownMenuItem>New Team</DropdownMenuItem>
5557
</DropdownMenuGroup>
5658
<DropdownMenuSeparator />
5759
<DropdownMenuItem

0 commit comments

Comments
 (0)