import type { CurrentUser, SiteSettings } from '../../env';
import { AdminLayout } from './layout';

export function AdminAuditPage(props: {
  settings: SiteSettings;
  currentUser: CurrentUser;
  csrfToken: string;
  logs: Array<{ id: number; actor_id: string | null; action: string; target: string | null; detail: string | null; ip: string | null; created_at: number }>;
}) {
  return (
    <AdminLayout title="审计日志" settings={props.settings} currentUser={props.currentUser} csrfToken={props.csrfToken} active="/admin/audit">
      <section class="admin-panel">
        <table class="admin-table">
          <thead><tr><th>ID</th><th>动作</th><th>目标</th><th>详情</th><th>IP</th></tr></thead>
          <tbody>
            {props.logs.map((log) => (
              <tr>
                <td>{log.id}</td>
                <td>{log.action}</td>
                <td>{log.target}</td>
                <td><code>{log.detail}</code></td>
                <td>{log.ip}</td>
              </tr>
            ))}
          </tbody>
        </table>
      </section>
    </AdminLayout>
  );
}
