All files / components/componentClient ClientsTableRow.tsx

33.33% Statements 1/3
0% Branches 0/8
0% Functions 0/2
33.33% Lines 1/3

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                        1x                                                                                                  
'use client';
 
import { Client } from '@/types/client/client';
 
interface Props {
  client: Client;
  onToggleActive: (clientId: number) => void;
}
 
/**
 * Composant pour afficher une ligne de client dans la table
 */
export default function ClientsTableRow({ client, onToggleActive }: Props) {
  return (
    <tr className="hover:bg-gray-50">
      <td className="px-6 py-4 whitespace-nowrap">
        <div className="text-sm font-medium text-gray-900">#{client.id}</div>
      </td>
      <td className="px-6 py-4 whitespace-nowrap">
        <div className="text-sm font-medium text-gray-900">{client.nom}</div>
      </td>
      <td className="px-6 py-4 whitespace-nowrap">
        <div className="text-sm font-medium text-gray-900">{client.prenom}</div>
      </td>
      <td className="px-6 py-4 whitespace-nowrap">
        <div className="text-sm text-gray-900">{client.telephone}</div>
      </td>
      <td className="px-6 py-4 whitespace-nowrap">
        <div className="text-sm text-gray-900">{client.user.email}</div>
      </td>
      <td className="text-center">
        <span
          className={`inline-flex text-xs leading-5 font-semibold rounded-full ${
            client.user.is_active
              ? 'bg-green-100 text-green-800'
              : 'bg-red-100 text-red-800'
          }`}
        >
          {client.user.is_active ? 'Actif' : 'Inactif'}
        </span>
      </td>
      <td className="px-6 py-4 whitespace-nowrap">
        <div className="text-xs text-gray-500">
          Créé le : {new Date(client.user.date_joined).toLocaleDateString('fr-FR')}
        </div>
      </td>
      <td className="px-6 py-4 whitespace-nowrap text-center">
        <button
          className={`px-3 py-1 rounded text-xs font-semibold shadow ${
            client.user.is_active
              ? 'bg-red-500 text-white hover:bg-red-600'
              : 'bg-green-500 text-white hover:bg-green-600'
          }`}
          onClick={() => onToggleActive(client.id)}
        >
          {client.user.is_active ? 'Désactiver' : 'Activer'}
        </button>
      </td>
    </tr>
  );
}