import { isAuthenticated } from '@/lib/auth'

export default async function LoginPage({ searchParams }: { searchParams: Promise<{ error?: string }> }) {
  await isAuthenticated()

  const params = await searchParams

  return (
    <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', minHeight: '100vh' }}>
      <div className="card" style={{ width: 360 }}>
        <h2>Login WA Test</h2>
        <p>Masuk pakai akun hardcoded dulu.</p>
        {params.error ? <div className="error">{params.error}</div> : null}
        <form method="POST" action="/api/login">
          <label>Username</label>
          <input className="input" type="text" name="username" required />
          <label>Password</label>
          <input className="input" type="password" name="password" required />
          <button className="btn" type="submit" style={{ width: '100%' }}>Masuk</button>
        </form>
      </div>
    </div>
  )
}
