'use client'; import { Suspense, useState } from 'react'; import { useRouter, useSearchParams } from 'next/navigation'; function LoginInner() { const router = useRouter(); const params = useSearchParams(); const from = params.get('from') || '/admin'; const [password, setPassword] = useState(''); const [error, setError] = useState(null); const [busy, setBusy] = useState(false); async function submit(e: React.FormEvent) { e.preventDefault(); setBusy(true); setError(null); try { const res = await fetch('/api/admin/login', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ password }), }); if (res.ok) { router.replace(from); router.refresh(); } else { setError('Incorrect password.'); setBusy(false); } } catch { setError('Something went wrong. Try again.'); setBusy(false); } } return (
SA

Content CMS

soroushasadi.ir

setPassword(e.target.value)} className="w-full rounded-lg border border-white/10 bg-base-900/60 px-3 py-2.5 text-sm text-slate-100 outline-none focus:border-electric/60" placeholder="••••••••" /> {error &&

{error}

}
); } export default function AdminLoginPage() { return ( ); }