'use client';
import { authClient } from '@/lib/auth-client';
import { useEffect, useState } from 'react';

export default function TestApi() {
  const [result, setResult] = useState<any>(null);
  const [error, setError] = useState<string | null>(null);

  useEffect(() => {
    async function test() {
      try {
        const response = await authClient.signIn.email({
          email: 'david@dhg.lol',
          password: 'admin1234'
        });
        setResult(response);
      } catch (err: any) {
        setError(err.message);
      }
    }
    test();
  }, []);

  return (
    <div style={{ padding: '2rem' }}>
      <h1>Test Auth API</h1>
      {error && <p style={{ color: 'red' }}>Error: {error}</p>}
      {result && <pre>{JSON.stringify(result, null, 2)}</pre>}
      {!result && !error && <p>Loading...</p>}
    </div>
  );
}
