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 { Globe, 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 ExternalApis() {
const navigate = useNavigate();
const { currentOrganization } = useOrganizationStore();
const organizationId = currentOrganization?.id;
const { data: apis, isLoading } = useQuery({
queryKey: ['external-apis', organizationId],
queryFn: async () => {
const response = await api.get('/external-apis');
return response.data.data || [];
}
});
const sidebar = (
<EntitySidebar
items={apis || []}
getItemHref={(a) => `/${organizationId}/backoffice/external-apis/${a._id || a.id}`}
searchPlaceholder="Rechercher une API..."
emptyMessage="Aucune API externe disponible"
title="APIs externes"
icon={Globe}
iconClass="text-cyan-600"
backofficeTo={`/${organizationId}/backoffice/external-apis/new`}
backofficeManageLabel="Créer une API externe"
backofficeCreateLabel="Créer une API externe"
createOnly
loading={isLoading}
filterFn={(a) => `${a.name} ${a.description || ''}`}
renderItem={(a, isSelected) => (
<>
<div className="flex items-center">
<Globe className={`w-4 h-4 mr-2 flex-shrink-0 ${isSelected ? 'text-cyan-400' : 'text-slate-500'}`} />
<span className={`text-sm font-medium truncate flex-1 ${isSelected ? 'text-white' : 'text-slate-300'}`}>
{a.name}
</span>
</div>
<div className="text-xs text-slate-400 truncate mt-0.5">
{a.url}
</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">
<Globe className="w-16 h-16 mx-auto mb-4 text-gray-300" />
<p className="text-gray-500">Sélectionnez une API externe dans la liste pour la gérer</p>
<button
onClick={() => navigate(`/${organizationId}/backoffice/external-apis/new`)}
className="mt-6 inline-flex items-center px-5 py-2.5 bg-cyan-600 text-white rounded-lg hover:bg-cyan-700 transition-colors"
>
<Plus className="w-5 h-5 mr-2" />
Créer une API externe
</button>
</div>
</div>
</div>
</BackofficeEntityPage>
);
} |