'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import { account, ID } from "../lib/appwrite"; export default function AuthPage() { const router = useRouter(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [err, setErr] = useState(''); const [isLogin, setIsLogin] = useState(true); const handleAuth = async (e) => { e.preventDefault(); try { if (isLogin) { await account.createEmailPasswordSession(email, password); router.push('/pages/dashboard'); } else { await account.create(ID.unique(), email, password); // Automatically log in after sign up await account.createEmailPasswordSession(email, password); router.push('/pages/dashboard'); } } catch (error) { console.error('Auth error:', error); setErr(error.message || 'Something went wrong'); } }; return (