"use client";

import { CollectionTable } from "@/components/collections/collection-table";
import { Badge } from "@/components/ui/badge";
import { Agent } from "@/lib/types";

export function AgentsTable() {
  const columns = [
    {
      key: "_id",
      label: "ID",
      render: (value: unknown) => (
        <span className="font-mono text-xs">{String(value).slice(-8)}</span>
      )
    },
    {
      key: "name",
      label: "Nom",
      render: (value: unknown) => (
        <span className="font-semibold">{String(value)}</span>
      )
    },
    {
      key: "description",
      label: "Description",
      render: (value: unknown) => (
        <span className="max-w-xs truncate">{String(value) || '-'}</span>
      )
    },
    {
      key: "category",
      label: "Catégorie",
      render: (value: unknown) => (
        <Badge variant="outline">{String(value)}</Badge>
      )
    },
    {
      key: "isActive",
      label: "Statut",
      render: (value: unknown) => (
        <Badge variant={value ? 'default' : 'destructive'}>
          {value ? 'Actif' : 'Inactif'}
        </Badge>
      )
    }
  ];

  return (
    <CollectionTable<Agent>
      collectionName="agents"
      title="Liste des agents"
      columns={columns}
    />
  );
}