We now have an AuthContext!
This commit is contained in:
@ -13,28 +13,17 @@ import {
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui';
|
||||
import { useProfile, useAvatar } from '@/lib/hooks';
|
||||
import { useAuth } from '@/components/context/auth';
|
||||
import { signOut } from '@/lib/actions';
|
||||
import { User } from 'lucide-react';
|
||||
|
||||
const AvatarDropdown = () => {
|
||||
const { profile } = useProfile();
|
||||
const { avatarUrl, isLoading } = useAvatar(profile);
|
||||
const { profile, avatarUrl, isLoading } = useAuth();
|
||||
|
||||
const handleSignOut = async () => {
|
||||
await signOut();
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<Avatar>
|
||||
<AvatarFallback className='animate-pulse'>
|
||||
<User size={32} />
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger>
|
||||
@ -60,13 +49,13 @@ const AvatarDropdown = () => {
|
||||
<DropdownMenuLabel>{profile?.full_name}</DropdownMenuLabel>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href='/profile' className='w-full justify-center'>
|
||||
<Link href='/profile' className='w-full justify-center cursor-pointer'>
|
||||
Edit profile
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator className='h-[2px]' />
|
||||
<DropdownMenuItem asChild>
|
||||
<button onClick={handleSignOut} className='w-full justify-center'>
|
||||
<button onClick={handleSignOut} className='w-full justify-center cursor-pointer'>
|
||||
Log out
|
||||
</button>
|
||||
</DropdownMenuItem>
|
||||
|
Reference in New Issue
Block a user