-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat+refactor(ui): Use single complete supabase provider + add user c…
…ontext to nav elements
- Loading branch information
1 parent
e88ac34
commit feb161f
Showing
10 changed files
with
353 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" | ||
|
||
export default function UserAvatar() { | ||
return ( | ||
<Avatar> | ||
<AvatarImage | ||
src="https://media.licdn.com/dms/image/C5103AQEXlYZeTKuwyQ/profile-displayphoto-shrink_200_200/0/1582770649112?e=1715212800&v=beta&t=wqVZfVV4YwedybQFzKazeWmlQslMQ11t_NGMCqwpN-k" | ||
alt="@daryllimyt" | ||
/> | ||
<AvatarFallback>CN</AvatarFallback> | ||
</Avatar> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { KeyRound, LogOut, Settings, UserRound, UsersRound } from "lucide-react" | ||
import { useSessionContext, useUser } from "@/providers/session" | ||
import { KeyRound, LogOut, Settings, UsersRound } from "lucide-react" | ||
|
||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" | ||
import { Button } from "@/components/ui/button" | ||
import { | ||
DropdownMenu, | ||
|
@@ -11,46 +11,51 @@ import { | |
DropdownMenuSeparator, | ||
DropdownMenuTrigger, | ||
} from "@/components/ui/dropdown-menu" | ||
import UserAvatar from "@/components/user-avatar" | ||
|
||
const userDefaults = { | ||
name: "Test User", | ||
email: "[email protected]", | ||
} | ||
export function UserNav() { | ||
const { signOut } = useSessionContext() | ||
const user = useUser() | ||
console.log("user", user) | ||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="ghost" className="relative h-8 w-8 rounded-full"> | ||
<Avatar className="h-8 w-8"> | ||
<AvatarImage src="" alt="" /> | ||
<AvatarFallback> | ||
<UserRound className="h-5 w-5" /> | ||
</AvatarFallback> | ||
</Avatar> | ||
<UserAvatar /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent className="w-56 p-2" align="end" forceMount> | ||
<DropdownMenuLabel className="font-normal"> | ||
<div className="flex flex-col space-y-1"> | ||
<p className="text-sm font-medium leading-none">shadcn</p> | ||
<p className="text-sm font-medium leading-none"> | ||
{user?.user_metadata.name ?? userDefaults.name} | ||
</p> | ||
<p className="text-xs leading-none text-muted-foreground"> | ||
[email protected] | ||
{user?.email ?? userDefaults.email} | ||
</p> | ||
</div> | ||
</DropdownMenuLabel> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuGroup> | ||
<DropdownMenuItem> | ||
<DropdownMenuItem className="hover:cursor-pointer"> | ||
<Settings className="mr-2 h-4 w-4" /> | ||
<span>Settings</span> | ||
Settings | ||
</DropdownMenuItem> | ||
<DropdownMenuItem> | ||
<DropdownMenuItem className="hover:cursor-pointer"> | ||
<KeyRound className="mr-2 h-4 w-4" /> | ||
<span>Credentials</span> | ||
</DropdownMenuItem> | ||
<DropdownMenuItem> | ||
<DropdownMenuItem className="hover:cursor-pointer"> | ||
<UsersRound className="mr-2 h-4 w-4" /> | ||
<span>Manage users</span> | ||
</DropdownMenuItem> | ||
</DropdownMenuGroup> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuItem> | ||
<DropdownMenuItem className="hover:cursor-pointer" onClick={signOut}> | ||
<LogOut className="mr-2 h-4 w-4" /> | ||
<span>Logout</span> | ||
</DropdownMenuItem> | ||
|
Oops, something went wrong.