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 73 74 75 76 77 78 | import { useNavigate } from 'react-router-dom';
import { Bug, Plus, Play, Clock } 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 Crawlers() {
const navigate = useNavigate();
const { currentOrganization } = useOrganizationStore();
const organizationId = currentOrganization?.id;
const { data: crawlers, isLoading } = useQuery({
queryKey: ['crawlers', organizationId],
queryFn: async () => {
const response = await api.get('/crawlers');
return response.data.data || [];
}
});
const sidebar = (
<EntitySidebar
items={crawlers || []}
getItemHref={(c) => `/${organizationId}/backoffice/crawlers/${c._id || c.id}`}
searchPlaceholder="Rechercher un crawler..."
emptyMessage="Aucun crawler disponible"
title="Crawlers"
icon={Bug}
iconClass="text-indigo-600"
backofficeTo={`/${organizationId}/backoffice/crawlers/new`}
backofficeManageLabel="Créer un crawler"
backofficeCreateLabel="Créer un crawler"
createOnly
loading={isLoading}
filterFn={(c) => `${c.name} ${c.description || ''}`}
renderItem={(c, isSelected) => (
<>
<div className="flex items-center">
<Bug className={`w-4 h-4 mr-2 flex-shrink-0 ${isSelected ? 'text-indigo-600' : 'text-gray-400'}`} />
<span className={`text-sm font-medium truncate flex-1 ${isSelected ? 'text-gray-900' : 'text-gray-700'}`}>
{c.name}
</span>
</div>
<div className="flex items-center gap-2 mt-0.5">
{c.description && <span className="text-xs text-gray-500 truncate">{c.description}</span>}
{c.runCount > 0 && (
<span className="text-xs text-gray-400 flex items-center flex-shrink-0">
<Clock className="w-3 h-3 mr-0.5" />
{c.runCount}
</span>
)}
</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">
<Bug className="w-16 h-16 mx-auto mb-4 text-gray-300" />
<p className="text-gray-500">Sélectionnez un crawler dans la liste pour le gérer</p>
<button
onClick={() => navigate(`/${organizationId}/backoffice/crawlers/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 crawler
</button>
</div>
</div>
</div>
</BackofficeEntityPage>
);
} |