Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | import { useNavigate } from 'react-router-dom';
import { Bot, Plus } from 'lucide-react';
import { useQuery } from '@tanstack/react-query';
import api from '../../services/api';
import { useOrganizationStore } from '../../store/organizationStore';
import EntitySidebar from '../../components/EntitySidebar';
import BackofficeEntityPage from '../components/BackofficeEntityPage';
export default function Agents() {
const navigate = useNavigate();
const { currentOrganization } = useOrganizationStore();
const organizationId = currentOrganization?.id;
const { data: agents, isLoading } = useQuery({
queryKey: ['agents', organizationId],
queryFn: async () => {
const response = await api.get('/agents');
return response.data.data?.agents || [];
}
});
const sidebar = (
<EntitySidebar
items={agents || []}
getItemHref={(agent) => `/${organizationId}/backoffice/agents/${agent.id}`}
searchPlaceholder="Rechercher un agent..."
emptyMessage="Aucun agent disponible"
title="Agents"
icon={Bot}
iconClass="text-purple-600"
backofficeTo={`/${organizationId}/backoffice/agents/new`}
backofficeManageLabel="Créer un agent"
backofficeCreateLabel="Créer un agent"
createOnly
loading={isLoading}
filterFn={(a) => `${a.name} ${a.description || ''}`}
renderItem={(agent, isSelected) => (
<>
<div className="flex items-center">
<Bot className={`w-4 h-4 mr-2 flex-shrink-0 ${isSelected ? 'text-purple-600' : 'text-gray-400'}`} />
<span className={`text-sm font-medium truncate flex-1 ${isSelected ? 'text-gray-900' : 'text-gray-700'}`}>
{agent.name}
</span>
</div>
{agent.description && (
<div className="text-xs text-gray-500 truncate mt-0.5">{agent.description}</div>
)}
</>
)}
/>
);
return (
<BackofficeEntityPage selectedId={null} sidebar={sidebar}>
<div className="flex-1 min-h-0 overflow-y-auto p-3 sm:p-6">
<div className="h-full flex items-center justify-center">
<div className="text-center">
<Bot className="w-16 h-16 mx-auto mb-4 text-gray-300" />
<p className="text-gray-500">Sélectionnez un agent dans la liste pour le gérer</p>
<button
onClick={() => navigate(`/${organizationId}/backoffice/agents/new`)}
className="mt-6 inline-flex items-center px-5 py-2.5 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition-colors"
>
<Plus className="w-5 h-5 mr-2" />
Créer un agent
</button>
</div>
</div>
</div>
</BackofficeEntityPage>
);
} |