%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home2/rezakur1/ai.rezakurnia.com/zh-router-frontend/src/components/dashboard/
Upload File :
Create Path :
Current File : //home2/rezakur1/ai.rezakurnia.com/zh-router-frontend/src/components/dashboard/ActivityTable.tsx

import type { ActivityItem } from "@/types/api";
import Badge from "@/components/ui/Badge";
import { formatCompact, formatDateTime } from "@/lib/format";

function statusTone(status: number): "success" | "danger" | "warning" {
  if (status >= 200 && status < 300) return "success";
  if (status >= 400) return "danger";
  return "warning";
}

export default function ActivityTable({ items }: { items: ActivityItem[] }) {
  if (items.length === 0) {
    return (
      <div className="py-10 text-center text-sm text-slate-500">
        Belum ada aktivitas tercatat.
      </div>
    );
  }

  return (
    <div className="overflow-x-auto">
      <table className="w-full min-w-[640px] text-left text-sm">
        <thead>
          <tr className="border-b border-white/[0.06] bg-white/[0.02] text-[11px] uppercase tracking-wider text-slate-500">
            <th className="px-5 py-3 font-semibold">Endpoint</th>
            <th className="px-4 py-3 font-semibold">Status</th>
            <th className="px-4 py-3 font-semibold">Key</th>
            <th className="px-4 py-3 text-right font-semibold">Input</th>
            <th className="px-4 py-3 text-right font-semibold">Cached</th>
            <th className="px-4 py-3 text-right font-semibold">Output</th>
            <th className="px-5 py-3 text-right font-semibold">Waktu</th>
          </tr>
        </thead>
        <tbody>
          {items.map((item) => (
            <tr
              key={item.id}
              className="border-b border-white/[0.04] transition-colors last:border-0 hover:bg-white/[0.02]"
            >
              <td className="px-5 py-3">
                <span className="font-mono text-xs text-slate-300">
                  {item.endpoint}
                </span>
              </td>
              <td className="px-4 py-3">
                <Badge tone={statusTone(item.http_status)}>
                  {item.http_status}
                </Badge>
              </td>
              <td className="px-4 py-3 text-xs text-slate-400">
                {item.key_name}
                <span className="ml-1.5 font-mono text-[10px] text-slate-600">
                  {item.key_prefix}
                </span>
              </td>
              <td className="px-4 py-3 text-right font-medium tabular-nums text-slate-300">
                {formatCompact(item.input_tokens)}
              </td>
              <td className="px-4 py-3 text-right font-medium tabular-nums text-slate-500">
                {formatCompact(item.cached_tokens)}
              </td>
              <td className="px-4 py-3 text-right font-medium tabular-nums text-slate-300">
                {formatCompact(item.output_tokens)}
              </td>
              <td className="px-5 py-3 text-right text-xs tabular-nums text-slate-500">
                {formatDateTime(item.created_at)}
              </td>
            </tr>
          ))}
        </tbody>
      </table>
    </div>
  );
}

Zerion Mini Shell 1.0