import { useState, useEffect } from "react"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { useAuth, registrationSchema, RegistrationData } from "@/hooks/use-auth"; import { useLocation } from "wouter"; import { loginSchema, Login } from "@shared/schema"; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Checkbox } from "@/components/ui/checkbox"; import { Loader2 } from "lucide-react"; export default function AuthPage() { const { user, loginMutation, registerMutation } = useAuth(); const [_, navigate] = useLocation(); const [activeTab, setActiveTab] = useState<"login" | "register">("login"); // Redirect if user is already logged in useEffect(() => { if (user) { navigate("/"); } }, [user, navigate]); // Set meta data for SEO useEffect(() => { document.title = "Login or Sign Up | Pilates with Fadia"; const metaDescription = document.querySelector('meta[name="description"]'); if (metaDescription) { metaDescription.setAttribute("content", "Create an account or login to book classes, access community features, and more with Pilates with Fadia."); } }, []); // Login form const loginForm = useForm({ resolver: zodResolver(loginSchema), defaultValues: { username: "", password: "", }, }); // Registration form const registerForm = useForm({ resolver: zodResolver(registrationSchema), defaultValues: { username: "", email: "", fullName: "", password: "", confirmPassword: "", }, }); const onLoginSubmit = (data: Login) => { loginMutation.mutate(data); }; const onRegisterSubmit = (data: RegistrationData) => { // Remove confirmPassword before sending to API const { confirmPassword, ...registerData } = data; registerMutation.mutate(registerData); }; return (
{/* Left column with auth forms */}
setActiveTab(value as "login" | "register")} className="w-full"> Login Sign Up Welcome Back Login to access your account
( Username )} /> ( Password )} />
Forgot password?
Create an Account Sign up to book classes and access exclusive content
( Username )} /> ( Email )} /> ( Full Name )} /> ( Password )} /> ( Confirm Password )} />
{/* Right column with hero section */}

Begin Your Pilates Journey

Join our community of wellness enthusiasts and transform your body and mind through the art of Pilates. Create an account to access:

  • Convenient class booking and scheduling
  • Community resources and support
  • Special member-only workshops
  • Personalized fitness tracking

"The mind, when housed within a healthful body, possesses a glorious sense of power."

); }