'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; import { useAuth } from '../../context/AuthContext'; export default function SignUpPage() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const router = useRouter(); const { signUp, signInWithGoogle } = useAuth(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (password !== confirmPassword) { return setError('Passwords do not match'); } try { setError(''); setLoading(true); await signUp(email, password); router.push('/'); // Redirect to home page after successful signup } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : 'Failed to create an account'; setError(errorMessage); } finally { setLoading(false); } }; const handleGoogleSignIn = async () => { try { setError(''); setLoading(true); await signInWithGoogle(); router.push('/'); } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : 'Failed to sign up with Google'; setError(errorMessage); } finally { setLoading(false); } }; return (