"use client"; import type React from "react"; import { useState } from "react"; import { useRouter } from "next/navigation"; import Link from "next/link"; import { toast } from "sonner"; import { useAuth } from "@/hooks/use-auth"; import { signupUserApi } from "@/services/api-auth"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Icons } from "@/components/icons"; import { Checkbox } from "@/components/ui/checkbox"; import Image from "next/image"; export default function SignupPage() { const router = useRouter(); const { login } = useAuth(); const [isLoading, setIsLoading] = useState(false); const [formData, setFormData] = useState({ firstName: "", lastName: "", email: "", password: "", }); const [showPassword, setShowPassword] = useState(false); const [agreedToTerms, setAgreedToTerms] = useState(false); const handleChange = (e: React.ChangeEvent) => { const { name, value } = e.target; setFormData((prev) => ({ ...prev, [name]: value })); }; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!agreedToTerms) { toast.error("You must agree to the Terms & Conditions"); return; } setIsLoading(true); try { const { firstName, lastName, email, password } = formData; const username = `${firstName} ${lastName}`.trim(); const user = await signupUserApi({ username, email, password }); // In a real app, we'd get a token back from signup or do a separate login // For now, we'll simulate getting a token login("dummy-token", user); toast.success("Account created successfully"); router.push("/todos"); } catch (error) { console.error("Signup failed:", error); toast.error("Signup failed. Please try again."); } finally { setIsLoading(false); } }; return (
{/* Left side - Image */}
Background
TODO

Capturing Moments,
Creating Memories

{/* Right side - Form */}
TODO Back to website

Create an account

Already have an account?{" "} Log in

setAgreedToTerms(checked as boolean) } className="border-gray-300 data-[state=checked]:bg-[#FF5A5F]" />
Or register with
); }