diff --git a/app/login/page.tsx b/app/login/page.tsx index f88bfe4..7c77b23 100644 --- a/app/login/page.tsx +++ b/app/login/page.tsx @@ -1,15 +1,14 @@ 'use client'; -import { useState } from 'react'; -import { useRouter } from 'next/navigation'; +import { useState, useRef } from 'react'; export default function LoginPage() { - const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); - const router = useRouter(); + const inputRef = useRef(null); async function handleLogin() { + const password = inputRef.current?.value || ''; if (!password || loading) return; setLoading(true); setError(''); @@ -21,39 +20,31 @@ export default function LoginPage() { body: JSON.stringify({ password }), }); if (!res.ok) throw new Error('Invalid password'); - router.push('/'); - router.refresh(); + window.location.href = '/'; } catch { setError('Invalid password'); setLoading(false); } } - function handleKeyDown(e: React.KeyboardEvent) { - if (e.key === 'Enter') handleLogin(); - } - return ( -
-
+
+
Aaron AI @@ -64,13 +55,12 @@ export default function LoginPage() {
setPassword(e.target.value)} - onKeyDown={handleKeyDown} placeholder="Password" autoFocus autoComplete="current-password" + onKeyDown={e => e.key === 'Enter' && handleLogin()} style={{ width: '100%', background: '#faf9f6', @@ -94,7 +84,6 @@ export default function LoginPage() {