'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' export default function LoginPage() { const router = useRouter() const [pw, setPw] = useState('') const [err, setErr] = useState('') const [loading, setLoading] = useState(false) async function login(e: React.FormEvent) { e.preventDefault() setLoading(true); setErr('') const res = await fetch('/api/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ password: pw }) }) if (res.ok) router.push('/dashboard') else { setErr((await res.json()).error ?? 'Hata'); setLoading(false) } } return (