import { useEffect, useState } from "react";
import api from "../api";
import EmptyState from "../components/EmptyState";

export default function Security() {
  const [logs, setLogs] = useState<any[]>([]);

  useEffect(()=>{ api.get("/admin/security/anomalies").then(r=>setLogs(r.data)); },[]);

  if (!logs.length) return <EmptyState text="No security events" />;

  return (
    <>
      {logs.map(l=>(
        <div key={l._id} className="bg-red-900/40 p-2 rounded mb-2">
          🤖 {l.action} · {l.ip}
        </div>
      ))}
    </>
  );
}
