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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | 2x 2x 2x 23x 57x | import { Lieu } from '@/types/sportEvenement/lieu';
import LieuxTableRow from './LieuxTableRow';
import Spinner from '@/components/spinner';
interface LieuxTableProps {
lieux: Lieu[];
loading: boolean;
searchTerm: string;
onRefresh: () => void;
onDelete: (id: number) => void;
onEdit: (lieu: Lieu) => void;
error: string | null;
}
export default function LieuxTable({
lieux,
loading,
searchTerm,
onRefresh,
onDelete,
onEdit,
error
}: LieuxTableProps) {
return (
<div className="bg-white rounded-lg shadow-md overflow-hidden">
<div className="px-6 py-4 border-b border-gray-200">
<div className="flex justify-between items-center">
<h2 className="text-xl font-semibold text-gray-900">
Lieux ({lieux.length})
</h2>
<div className="flex items-center space-x-2">
{loading && (
<div className="flex items-center text-sm text-gray-500">
<Spinner size="small" />
Chargement...
</div>
)}
<button
onClick={onRefresh}
className="text-blue-600 hover:text-blue-800 text-sm font-medium"
disabled={loading}
>
🔄 Actualiser
</button>
</div>
</div>
{error && (
<div className="mt-2 text-sm text-red-600 bg-red-50 p-2 rounded">
{error}
</div>
)}
</div>
<div className="overflow-x-auto">
<table className="min-w-full divide-y divide-gray-200">
<thead className="bg-gray-50">
<tr>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Nom du Lieu
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Actions
</th>
</tr>
</thead>
<tbody className="bg-white divide-y divide-gray-200">
{lieux.length === 0 ? (
<tr>
<td colSpan={3} className="px-6 py-12 text-center text-gray-500">
{loading ? (
<div className="flex items-center justify-center">
<Spinner size="medium" />
Chargement des lieux...
</div>
) : searchTerm ? (
<div>
<p className="text-lg font-medium">Aucun lieu trouvé</p>
<p className="text-sm">Aucun lieu ne correspond à votre recherche “{searchTerm}”</p>
</div>
) : (
<div>
<p className="text-lg font-medium">Aucun lieu</p>
<p className="text-sm">Commencez par créer votre premier lieu</p>
</div>
)}
</td>
</tr>
) : (
lieux.map((lieu) => (
<LieuxTableRow
key={lieu.id}
lieu={lieu}
onDelete={onDelete}
onEdit={onEdit}
/>
))
)}
</tbody>
</table>
</div>
</div>
);
}
|