diff --git a/src/components/Header.tsx b/src/components/Header.tsx new file mode 100644 index 0000000..51cb807 --- /dev/null +++ b/src/components/Header.tsx @@ -0,0 +1,133 @@ +import { useState, useEffect } from "react"; +import { Link } from "react-router-dom"; +import { Button } from "@/components/ui/button"; +import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet"; +import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogTrigger } from "@/components/ui/dialog"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { Menu, Dumbbell } from "lucide-react"; +import { ThemeToggle } from "@/components/ThemeToggle"; +import { useAuth } from "@/hooks/use-tygarun"; +import { toast } from "sonner"; + +function AuthDialog({ trigger }: { trigger: React.ReactNode }) { + const { user, isSignedIn, signup, signin, signout } = useAuth(); + const [openAuth, setOpenAuth] = useState(false); + const [mode, setMode] = useState<"signin" | "signup">("signup"); + const [name, setName] = useState(""); + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [busy, setBusy] = useState(false); + + if (isSignedIn) { + return ( + + ); + } + + const submit = async (e: React.FormEvent) => { + e.preventDefault(); + setBusy(true); + try { + if (mode === "signup") await signup({ name, email, password }); + else await signin(email, password); + toast.success(mode === "signup" ? "Welcome to the crew!" : "Welcome back!"); + setOpenAuth(false); + setName(""); setEmail(""); setPassword(""); + } catch { + toast.error("Authentication failed. Please try again."); + } finally { + setBusy(false); + } + }; + + return ( + + {trigger} + + + {mode === "signup" ? "Join the Gym" : "Member Login"} + {mode === "signup" ? "Create your member account to book classes and manage your membership." : "Sign in to your member account."} + +
+ {mode === "signup" && ( +
+ + setName(e.target.value)} required className="bg-slate-900 border-slate-700" /> +
+ )} +
+ + setEmail(e.target.value)} required className="bg-slate-900 border-slate-700" /> +
+
+ + setPassword(e.target.value)} required className="bg-slate-900 border-slate-700" /> +
+ +
+ +
+
+ ); +} + +export default function Header() { + const [open, setOpen] = useState(false); + const [scrolled, setScrolled] = useState(false); + + useEffect(() => { + const fn = () => setScrolled(window.scrollY > 20); + window.addEventListener("scroll", fn); + return () => window.removeEventListener("scroll", fn); + }, []); + + const links = [ + { label: "Classes", to: "/classes" }, + { label: "Trainers", to: "/trainers" }, + { label: "Pricing", to: "/pricing" }, + { label: "Contact", to: "/contact" }, + ]; + + return ( +
+
+ +
+ +
+ Apex Fitness + + +
+ + Join Now} /> +
+ + + + + + + + +
+
+ ); +} \ No newline at end of file