Spaces:
Build error
Build error
| import Link from 'next/link'; | |
| import { useAuth } from '@/context/AuthContext'; | |
| import { Image as ImageIcon, Activity, CreditCard, User, LogOut, LogIn, Sparkles } from 'lucide-react'; | |
| import { useState } from 'react'; | |
| import AuthModal from './AuthModal'; | |
| import PricingModal from './PricingModal'; | |
| export default function Navbar() { | |
| const { user, logout, credits } = useAuth(); | |
| const [isAuthModalOpen, setIsAuthModalOpen] = useState(false); | |
| const [isPricingOpen, setIsPricingOpen] = useState(false); | |
| return ( | |
| <nav className="border-b border-border bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 sticky top-0 z-40"> | |
| <div className="container mx-auto px-4 h-16 flex items-center justify-between"> | |
| {/* Logo */} | |
| <div className="flex items-center gap-2"> | |
| <div className="bg-primary p-2 rounded-lg"> | |
| <Sparkles className="h-5 w-5 text-primary-foreground" /> | |
| </div> | |
| <span className="font-bold text-xl tracking-tight">AI Studio</span> | |
| </div> | |
| {/* Navigation Links */} | |
| <div className="hidden md:flex items-center gap-6"> | |
| <Link href="/" className="text-sm font-medium text-muted-foreground hover:text-primary transition-colors flex items-center gap-2"> | |
| <ImageIcon className="h-4 w-4" /> Editor | |
| </Link> | |
| <Link href="/pose" className="text-sm font-medium text-muted-foreground hover:text-primary transition-colors flex items-center gap-2"> | |
| <Activity className="h-4 w-4" /> Pose Editor | |
| </Link> | |
| <button | |
| onClick={() => setIsPricingOpen(true)} | |
| className="text-sm font-medium text-muted-foreground hover:text-primary transition-colors flex items-center gap-2" | |
| > | |
| <CreditCard className="h-4 w-4" /> Pricing | |
| </button> | |
| </div> | |
| {/* Right Side Actions */} | |
| <div className="flex items-center gap-4"> | |
| {user ? ( | |
| <> | |
| <div className="hidden sm:flex items-center gap-2 px-3 py-1.5 bg-secondary rounded-full border border-border"> | |
| <CreditCard className="h-3 w-3 text-primary" /> | |
| <span className="text-xs font-semibold text-primary-foreground">{credits} Credits</span> | |
| </div> | |
| <div className="relative group"> | |
| <button className="flex items-center gap-2 hover:bg-secondary px-3 py-1.5 rounded-md transition-colors"> | |
| <div className="h-8 w-8 bg-primary/20 rounded-full flex items-center justify-center text-primary font-bold text-sm"> | |
| {user.name[0].toUpperCase()} | |
| </div> | |
| <span className="text-sm font-medium hidden lg:block">{user.name}</span> | |
| </button> | |
| {/* Dropdown */} | |
| <div className="absolute right-0 mt-2 w-48 bg-popover border border-border rounded-md shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all transform origin-top-right"> | |
| <div className="py-1"> | |
| <Link href="/account" className="block px-4 py-2 text-sm text-foreground hover:bg-accent hover:text-accent-foreground flex items-center gap-2"> | |
| <User className="h-4 w-4" /> Account | |
| </Link> | |
| <button | |
| onClick={logout} | |
| className="w-full text-left px-4 py-2 text-sm text-destructive hover:bg-accent/50 flex items-center gap-2" | |
| > | |
| <LogOut className="h-4 w-4" /> Logout | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </> | |
| ) : ( | |
| <button | |
| onClick={() => setIsAuthModalOpen(true)} | |
| className="bg-primary text-primary-foreground hover:bg-primary/90 px-4 py-2 rounded-md text-sm font-medium transition-colors flex items-center gap-2" | |
| > | |
| <LogIn className="h-4 w-4" /> Login | |
| </button> | |
| )} | |
| </div> | |
| </div> | |
| <AuthModal open={isAuthModalOpen} onOpenChange={setIsAuthModalOpen} /> | |
| <PricingModal open={isPricingOpen} onOpenChange={setIsPricingOpen} /> | |
| </nav> | |
| ); | |
| } |