mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 09:51:13 -05:00
Visual edit in Lovable
This commit is contained in:
@@ -2,68 +2,51 @@ import { useState } from 'react';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||||
import {
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
|
||||||
DropdownMenu,
|
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuItem,
|
|
||||||
DropdownMenuLabel,
|
|
||||||
DropdownMenuSeparator,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
} from '@/components/ui/dropdown-menu';
|
|
||||||
import { User, Settings, LogOut, Trophy } from 'lucide-react';
|
import { User, Settings, LogOut, Trophy } from 'lucide-react';
|
||||||
import { useAuth } from '@/hooks/useAuth';
|
import { useAuth } from '@/hooks/useAuth';
|
||||||
import { useToast } from '@/hooks/use-toast';
|
import { useToast } from '@/hooks/use-toast';
|
||||||
|
|
||||||
export function AuthButtons() {
|
export function AuthButtons() {
|
||||||
const { user, profile, signOut } = useAuth();
|
const {
|
||||||
|
user,
|
||||||
|
profile,
|
||||||
|
signOut
|
||||||
|
} = useAuth();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { toast } = useToast();
|
const {
|
||||||
|
toast
|
||||||
|
} = useToast();
|
||||||
const [loggingOut, setLoggingOut] = useState(false);
|
const [loggingOut, setLoggingOut] = useState(false);
|
||||||
|
|
||||||
const handleSignOut = async () => {
|
const handleSignOut = async () => {
|
||||||
setLoggingOut(true);
|
setLoggingOut(true);
|
||||||
try {
|
try {
|
||||||
await signOut();
|
await signOut();
|
||||||
toast({
|
toast({
|
||||||
title: "Signed out",
|
title: "Signed out",
|
||||||
description: "You've been signed out successfully.",
|
description: "You've been signed out successfully."
|
||||||
});
|
});
|
||||||
navigate('/');
|
navigate('/');
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
toast({
|
toast({
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
title: "Error signing out",
|
title: "Error signing out",
|
||||||
description: error.message,
|
description: error.message
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
setLoggingOut(false);
|
setLoggingOut(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return (
|
return <>
|
||||||
<>
|
<Button variant="ghost" size="sm" className="hidden sm:flex" onClick={() => navigate('/auth?tab=signin')}>
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
className="hidden sm:flex"
|
|
||||||
onClick={() => navigate('/auth?tab=signin')}
|
|
||||||
>
|
|
||||||
Sign In
|
Sign In
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button size="sm" className="bg-gradient-to-r from-primary to-accent hover:from-primary/90 hover:to-accent/90" onClick={() => navigate('/auth?tab=signup')}>
|
||||||
size="sm"
|
|
||||||
className="bg-gradient-to-r from-primary to-accent hover:from-primary/90 hover:to-accent/90"
|
|
||||||
onClick={() => navigate('/auth?tab=signup')}
|
|
||||||
>
|
|
||||||
Join ThrillWiki
|
Join ThrillWiki
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
</>;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
return <DropdownMenu>
|
||||||
return (
|
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button variant="ghost" className="relative h-8 w-8 rounded-full">
|
<Button variant="ghost" className="relative h-8 w-8 rounded-full">
|
||||||
<Avatar className="h-8 w-8">
|
<Avatar className="h-8 w-8">
|
||||||
@@ -90,10 +73,7 @@ export function AuthButtons() {
|
|||||||
<User className="mr-2 h-4 w-4" />
|
<User className="mr-2 h-4 w-4" />
|
||||||
<span>Profile</span>
|
<span>Profile</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem onClick={() => navigate('/profile#lists')}>
|
|
||||||
<Trophy className="mr-2 h-4 w-4" />
|
|
||||||
<span>My Lists</span>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem onClick={() => navigate('/settings')}>
|
<DropdownMenuItem onClick={() => navigate('/settings')}>
|
||||||
<Settings className="mr-2 h-4 w-4" />
|
<Settings className="mr-2 h-4 w-4" />
|
||||||
<span>Settings</span>
|
<span>Settings</span>
|
||||||
@@ -104,6 +84,5 @@ export function AuthButtons() {
|
|||||||
<span>{loggingOut ? 'Signing out...' : 'Sign out'}</span>
|
<span>{loggingOut ? 'Signing out...' : 'Sign out'}</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user