Refactor: Simplify auth and profile handling

This commit is contained in:
gpt-engineer-app[bot]
2025-10-13 17:22:56 +00:00
parent be26c08640
commit 149c0704fe
9 changed files with 78 additions and 122 deletions

View File

@@ -5,16 +5,13 @@ import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
import { User, Settings, LogOut } from 'lucide-react';
import { useAuth } from '@/hooks/useAuth';
import { useProfile } from '@/hooks/useProfile';
import { useToast } from '@/hooks/use-toast';
import { AuthModal } from './AuthModal';
export function AuthButtons() {
const {
user,
profile,
loading,
signOut
} = useAuth();
const { user, loading: authLoading, signOut } = useAuth();
const { data: profile, isLoading: profileLoading } = useProfile(user?.id);
const navigate = useNavigate();
const {
toast
@@ -43,7 +40,7 @@ export function AuthButtons() {
};
// Show loading skeleton only during initial auth check
if (loading) {
if (authLoading) {
return (
<div className="flex gap-2 items-center">
<div className="h-8 w-16 bg-muted animate-pulse rounded" />
@@ -83,17 +80,6 @@ export function AuthButtons() {
</>
);
}
// Debug logging for avatar rendering
console.log('[AuthButtons] Component render:', {
hasUser: !!user,
hasProfile: !!profile,
hasAvatarUrl: !!profile?.avatar_url,
avatarUrl: profile?.avatar_url,
displayName: profile?.display_name,
username: profile?.username,
loading
});
return <DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" className="relative h-8 w-8 rounded-full">