'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; export default function AdminLoginPage() { const router = useRouter(); const [id, setId] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(''); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setError(''); setLoading(true); try { const res = await fetch('/api/admin/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id, password }), }); const data = await res.json(); if (!res.ok) { setError(data.error || '로그인에 실패했습니다.'); } else { router.push('/admin/dashboard'); } } catch { setError('서버 연결에 실패했습니다.'); } finally { setLoading(false); } } return (
{/* 로고 */}

관리자 로그인

쟁승메이드 관리자 전용

{/* 폼 */}
setId(e.target.value)} required autoComplete="off" className="w-full bg-slate-800 border border-slate-600 rounded-lg px-4 py-2.5 text-white text-sm placeholder-slate-500 focus:outline-none focus:border-red-500 focus:ring-1 focus:ring-red-500 transition" placeholder="관리자 ID 입력" />
setPassword(e.target.value)} required autoComplete="current-password" className="w-full bg-slate-800 border border-slate-600 rounded-lg px-4 py-2.5 text-white text-sm placeholder-slate-500 focus:outline-none focus:border-red-500 focus:ring-1 focus:ring-red-500 transition" placeholder="비밀번호 입력" />
{error && (
{error}
)}

관리자 전용 페이지입니다.

); }