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 105 106 107 | 2x 2x 2x 31x 71x | import { Epreuve } from '@/types/sportEvenement/epreuve';
import EpreuvesTableRow from './EpreuvesTableRow';
import Spinner from '@/components/spinner';
interface Props {
epreuves: Epreuve[];
loading: boolean;
searchTerm: string;
onRefresh: () => void;
onDelete: (id: number) => void;
onEdit: (epreuve: Epreuve) => void;
error: string | null;
}
export default function EpreuvesTable({
epreuves,
loading,
searchTerm,
onRefresh,
onDelete,
onEdit,
error
}: Props) {
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">
Épreuves ({epreuves.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">
Libellé de l'Épreuve
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Discipline
</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">
{epreuves.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 épreuves...
</div>
) : searchTerm ? (
<div>
<p className="text-lg font-medium">Aucune épreuve trouvée</p>
<p className="text-sm">Aucune épreuve ne correspond à votre recherche “{searchTerm}”</p>
</div>
) : (
<div>
<p className="text-lg font-medium">Aucune épreuve</p>
<p className="text-sm">Commencez par créer votre première épreuve</p>
</div>
)}
</td>
</tr>
) : (
epreuves.map((epreuve) => (
<EpreuvesTableRow
key={epreuve.id}
epreuve={epreuve}
onDelete={onDelete}
onEdit={onEdit}
/>
))
)}
</tbody>
</table>
</div>
</div>
);
}
|