All files / components/componentOffre OffresTable.tsx

60% Statements 3/5
0% Branches 0/6
0% Functions 0/2
60% Lines 3/5

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 861x   1x                   1x                                                                                                                                                  
import Spinner from '@/components/spinner';
import {Offre} from "@/types/offre/offre";
import OffresTableRow from "@/components/componentOffre/OffresTableRaw";
 
interface Props {
  offres: Offre[];
  loading: boolean;
  onDelete: (id: number) => void;
  onEdit: (offre: Offre) => void;
  error: string | null;
}
 
export default function OffresTable({
                                          offres,
                                          loading,
                                          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">
            Disciplines ({offres.length})
          </h2>
        </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 de l&apos;offre
              </th>
              <th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                nombre de personnes
              </th>
              <th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                Prix
              </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">
            {offres.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 offres...
                    </div>
                  ) :(
                    <div>
                      <p className="text-lg font-medium">Aucune offre</p>
                      <p className="text-sm">Commencez par créer votre première offre</p>
                    </div>
                  )}
                </td>
              </tr>
            ) : (
              offres.map((offre) => (
                <OffresTableRow
                  key={offre.id}
                  offre={offre}
                  onDelete={onDelete}
                  onEdit={onEdit}
                />
              ))
            )}
          </tbody>
        </table>
      </div>
    </div>
  );
}