Added few functions

This commit is contained in:
2026-02-16 14:43:02 +01:00
parent 0c908a21ac
commit 1ec4c935c9
31 changed files with 352 additions and 35 deletions

View File

@@ -3,6 +3,7 @@
import { useState, useEffect } from 'react';
import { useNotification } from './NotificationProvider';
import ConfirmModal from './ConfirmModal';
import { getParticipationRef } from '@/lib/participation-ref';
interface Trajet {
id: string;
@@ -12,6 +13,7 @@ interface Trajet {
commentaire?: string | null;
statut: string;
archived: boolean;
participations?: { id: string }[];
adherent: {
id: string;
nom: string;
@@ -117,14 +119,21 @@ export default function ArchivesTrajets() {
return `${prenom.charAt(0)}${nom.charAt(0)}`.toUpperCase();
};
const participationRef = (t: Trajet) => {
const p = t.participations?.[0];
return p ? getParticipationRef(p.id) : null;
};
const filteredTrajets = trajets.filter((trajet) => {
const ref = participationRef(trajet);
const searchLower = searchTerm.toLowerCase();
return (
trajet.adherent.nom.toLowerCase().includes(searchLower) ||
trajet.adherent.prenom.toLowerCase().includes(searchLower) ||
trajet.adresseDepart.toLowerCase().includes(searchLower) ||
trajet.adresseArrivee.toLowerCase().includes(searchLower) ||
(trajet.chauffeur && `${trajet.chauffeur.prenom} ${trajet.chauffeur.nom}`.toLowerCase().includes(searchLower))
(trajet.chauffeur && `${trajet.chauffeur.prenom} ${trajet.chauffeur.nom}`.toLowerCase().includes(searchLower)) ||
(ref && ref.toLowerCase().includes(searchLower))
);
});
@@ -144,7 +153,7 @@ export default function ArchivesTrajets() {
<div className="flex-1 relative">
<input
type="text"
placeholder="Rechercher dans les archives..."
placeholder="Rechercher (adhérent, adresse, référence PART-…)..."
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
className="w-full px-3 md:px-4 py-2 md:py-2.5 pl-9 md:pl-10 text-sm md:text-base border border-gray-300 rounded-lg focus:ring-2 focus:ring-lblue focus:border-transparent"
@@ -188,6 +197,11 @@ export default function ArchivesTrajets() {
{formatDate(trajet.date)} à {formatTime(trajet.date)}
</div>
</div>
{participationRef(trajet) && (
<span className="px-1.5 py-0.5 text-xs font-mono font-medium rounded bg-lblue/10 text-lblue flex-shrink-0" title="Référence de prescription">
{participationRef(trajet)}
</span>
)}
<span className={`px-2 py-1 text-xs font-medium rounded border ${getStatutColor(trajet.statut)} flex-shrink-0`}>
{trajet.statut}
</span>