Files
MAD-Platform/components/TrajetDetailModal.tsx

525 lines
25 KiB
TypeScript
Raw Normal View History

2026-01-21 17:48:14 +01:00
'use client';
import { useState } from 'react';
2026-01-22 19:25:25 +01:00
import dynamic from 'next/dynamic';
2026-01-21 17:48:14 +01:00
import TrajetForm from './TrajetForm';
2026-02-16 14:43:02 +01:00
import { getParticipationRef } from '@/lib/participation-ref';
import { useBodyScrollLock } from '@/lib/body-scroll-lock';
2026-01-21 17:48:14 +01:00
import ValidationModal from './ValidationModal';
2026-01-21 18:13:35 +01:00
import ConfirmModal from './ConfirmModal';
import { useNotification } from './NotificationProvider';
2026-01-21 17:48:14 +01:00
2026-01-22 19:25:25 +01:00
// Import dynamique pour éviter les problèmes SSR avec Leaflet
const TrajetMap = dynamic(() => import('./TrajetMap'), {
ssr: false,
loading: () => (
<div className="w-full h-full flex items-center justify-center bg-gray-100">
<div className="text-gray-500 text-sm">Chargement de la carte...</div>
</div>
)
});
2026-01-21 17:48:14 +01:00
interface Trajet {
id: string;
date: string;
adresseDepart: string;
adresseArrivee: string;
commentaire?: string | null;
2026-01-22 19:25:25 +01:00
instructions?: string | null;
2026-01-21 17:48:14 +01:00
statut: string;
2026-02-16 14:43:02 +01:00
participations?: { id: string }[];
2026-01-21 17:48:14 +01:00
adherent: {
id: string;
nom: string;
prenom: string;
telephone: string;
2026-01-22 19:25:25 +01:00
telephoneSecondaire?: string | null;
2026-01-21 17:48:14 +01:00
email: string;
2026-01-22 19:25:25 +01:00
forfait?: string | null;
2026-01-21 17:48:14 +01:00
};
chauffeur?: {
id: string;
nom: string;
prenom: string;
telephone: string;
} | null;
}
interface TrajetDetailModalProps {
trajet: Trajet;
onClose: () => void;
onUpdate: () => void;
}
export default function TrajetDetailModal({ trajet, onClose, onUpdate }: TrajetDetailModalProps) {
2026-01-21 18:13:35 +01:00
const { showNotification } = useNotification();
2026-02-16 14:43:02 +01:00
useBodyScrollLock(true);
2026-01-21 17:48:14 +01:00
const [showEditForm, setShowEditForm] = useState(false);
const [showValidationModal, setShowValidationModal] = useState(false);
2026-01-21 18:13:35 +01:00
const [showCancelConfirm, setShowCancelConfirm] = useState(false);
const [showArchiveConfirm, setShowArchiveConfirm] = useState(false);
2026-01-21 17:48:14 +01:00
const [loading, setLoading] = useState(false);
const formatDate = (dateString: string) => {
const date = new Date(dateString);
return date.toLocaleDateString('fr-FR', {
weekday: 'long',
day: 'numeric',
month: 'long',
year: 'numeric',
});
};
const formatTime = (dateString: string) => {
const date = new Date(dateString);
return date.toLocaleTimeString('fr-FR', { hour: '2-digit', minute: '2-digit' });
};
2026-01-21 18:13:35 +01:00
const handleCancelClick = () => {
setShowCancelConfirm(true);
};
2026-01-21 17:48:14 +01:00
2026-01-21 18:13:35 +01:00
const handleCancel = async () => {
setShowCancelConfirm(false);
2026-01-21 17:48:14 +01:00
setLoading(true);
try {
const response = await fetch(`/api/trajets/${trajet.id}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
statut: 'Annulé',
}),
});
if (response.ok) {
2026-01-21 18:13:35 +01:00
showNotification('info', 'Trajet annulé avec succès');
2026-01-21 17:48:14 +01:00
onUpdate();
onClose();
} else {
const error = await response.json();
2026-01-21 18:13:35 +01:00
showNotification('error', error.error || 'Erreur lors de l\'annulation du trajet');
2026-01-21 17:48:14 +01:00
}
} catch (error) {
console.error('Erreur lors de l\'annulation:', error);
2026-01-21 18:13:35 +01:00
showNotification('error', 'Erreur lors de l\'annulation du trajet');
} finally {
setLoading(false);
}
};
const handleArchiveClick = () => {
setShowArchiveConfirm(true);
};
const handleArchive = async () => {
setShowArchiveConfirm(false);
setLoading(true);
try {
const response = await fetch(`/api/trajets/${trajet.id}/archive`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
});
if (response.ok) {
showNotification('info', 'Trajet archivé avec succès');
onUpdate();
onClose();
} else {
const error = await response.json();
showNotification('error', error.error || 'Erreur lors de l\'archivage du trajet');
}
} catch (error) {
console.error('Erreur lors de l\'archivage:', error);
showNotification('error', 'Erreur lors de l\'archivage du trajet');
2026-01-21 17:48:14 +01:00
} finally {
setLoading(false);
}
};
const getInitials = (nom: string, prenom: string) => {
return `${prenom.charAt(0)}${nom.charAt(0)}`.toUpperCase();
};
const getStatutColor = (statut: string) => {
switch (statut) {
case 'Terminé':
return 'bg-green-100 text-green-700 border-green-200';
case 'En cours':
return 'bg-blue-100 text-blue-700 border-blue-200';
case 'Annulé':
return 'bg-red-100 text-red-700 border-red-200';
case 'Validé':
return 'bg-purple-100 text-purple-700 border-purple-200';
default:
return 'bg-gray-100 text-gray-700 border-gray-200';
}
};
2026-01-22 19:25:25 +01:00
const handleCopyAddress = async (address: string) => {
try {
await navigator.clipboard.writeText(address);
showNotification('success', 'Adresse copiée dans le presse-papiers');
} catch (error) {
console.error('Erreur lors de la copie:', error);
showNotification('error', 'Erreur lors de la copie de l\'adresse');
}
};
const handleOpenRoute = () => {
const encodedDepart = encodeURIComponent(trajet.adresseDepart);
const encodedArrivee = encodeURIComponent(trajet.adresseArrivee);
// Détecter le système d'exploitation pour ouvrir dans la bonne app
const userAgent = navigator.userAgent || navigator.vendor || (window as any).opera;
const isIOS = /iPad|iPhone|iPod/.test(userAgent) && !(window as any).MSStream;
if (isIOS) {
// Apple Maps avec itinéraire
window.open(`https://maps.apple.com/?saddr=${encodedDepart}&daddr=${encodedArrivee}`, '_blank');
} else {
// Google Maps avec itinéraire (par défaut sur Android et autres)
window.open(`https://www.google.com/maps/dir/${encodedDepart}/${encodedArrivee}`, '_blank');
}
};
2026-01-21 17:48:14 +01:00
if (showEditForm) {
return (
<TrajetForm
onClose={() => setShowEditForm(false)}
onSuccess={() => {
onUpdate();
setShowEditForm(false);
onClose();
}}
trajetToEdit={trajet}
/>
);
}
if (showValidationModal) {
return (
<ValidationModal
trajet={trajet}
onClose={() => setShowValidationModal(false)}
onSuccess={() => {
onUpdate();
setShowValidationModal(false);
onClose();
}}
/>
);
}
return (
2026-01-22 19:25:25 +01:00
<div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-2 sm:p-4 animate-fadeIn">
<div className="bg-white rounded-lg shadow-xl max-w-6xl w-full max-h-[95vh] sm:max-h-[90vh] overflow-hidden flex flex-col animate-slideUp border border-gray-200">
2026-01-21 17:48:14 +01:00
{/* Header */}
2026-01-22 19:25:25 +01:00
<div className="border-b border-gray-200 px-4 sm:px-6 py-4 sm:py-5 bg-white flex-shrink-0">
<div className="flex items-start justify-between gap-4">
<div className="flex-1 min-w-0">
<div className="flex items-center gap-3 mb-1">
<h2 className="text-xl sm:text-2xl font-semibold text-gray-900">Détails du trajet</h2>
2026-02-16 14:43:02 +01:00
{trajet.participations?.[0] && (
<span className="px-2 py-1 text-xs font-mono font-medium rounded-lg bg-lblue/10 text-lblue border border-lblue/20 flex-shrink-0" title="Référence de prescription">
{getParticipationRef(trajet.participations[0].id)}
</span>
)}
2026-01-22 19:25:25 +01:00
<span className={`px-2.5 sm:px-3 py-1 sm:py-1.5 text-xs sm:text-sm font-semibold rounded-lg border flex-shrink-0 ${getStatutColor(trajet.statut)}`}>
{trajet.statut}
</span>
</div>
<p className="text-xs sm:text-sm text-gray-500">Informations complètes du trajet</p>
2026-01-21 17:48:14 +01:00
</div>
<button
onClick={onClose}
2026-01-22 19:25:25 +01:00
className="text-gray-400 hover:text-gray-600 transition-colors p-2 hover:bg-gray-100 rounded-lg flex-shrink-0"
2026-01-21 17:48:14 +01:00
>
2026-01-22 19:25:25 +01:00
<svg className="w-5 h-5 sm:w-6 sm:h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2026-01-21 17:48:14 +01:00
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
</div>
{/* Content */}
2026-01-22 19:25:25 +01:00
<div className="flex-1 overflow-y-auto px-4 sm:px-6 py-4 sm:py-6">
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4 sm:gap-6">
{/* Colonne gauche - Informations */}
<div className="space-y-4 sm:space-y-6">
2026-01-21 17:48:14 +01:00
{/* Adhérent */}
<div>
<label className="text-sm font-medium text-gray-500 mb-2 block">Adhérent</label>
2026-01-22 19:25:25 +01:00
<div className="p-3 bg-gray-50 rounded-lg border border-gray-200">
<div className="flex items-center gap-3 mb-3">
<div className="w-12 h-12 rounded-full bg-lgreen flex items-center justify-center text-white font-semibold">
{getInitials(trajet.adherent.nom, trajet.adherent.prenom)}
</div>
<div className="flex-1">
<div className="text-sm font-semibold text-gray-900">
{trajet.adherent.prenom} {trajet.adherent.nom}
</div>
</div>
2026-01-21 17:48:14 +01:00
</div>
2026-01-22 19:25:25 +01:00
<div className="space-y-2 pt-2 border-t border-gray-200">
<div className="flex items-center gap-2">
<svg className="w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z" />
</svg>
<span className="text-xs text-gray-600">{trajet.adherent.telephone}</span>
2026-01-21 17:48:14 +01:00
</div>
2026-01-22 19:25:25 +01:00
{trajet.adherent.telephoneSecondaire && (
<div className="flex items-center gap-2">
<svg className="w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z" />
</svg>
<span className="text-xs text-gray-600">Secondaire: {trajet.adherent.telephoneSecondaire}</span>
</div>
)}
<div className="flex items-center gap-2">
<svg className="w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
</svg>
<span className="text-xs text-gray-600">{trajet.adherent.email}</span>
</div>
{trajet.adherent.forfait && (
<div className="flex items-center gap-2 text-xs sm:text-sm">
<svg className="w-4 h-4 text-gray-400 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span className="font-semibold text-lgreen">Forfait: {trajet.adherent.forfait} </span>
</div>
)}
2026-01-21 17:48:14 +01:00
</div>
</div>
</div>
{/* Chauffeur */}
{trajet.chauffeur ? (
<div>
2026-01-22 19:25:25 +01:00
<label className="text-xs sm:text-sm font-medium text-gray-500 mb-2 block">Chauffeur</label>
<div className="flex items-center gap-3 p-3 sm:p-4 bg-gray-50 rounded-lg border border-gray-200">
<div className="w-10 h-10 sm:w-12 sm:h-12 rounded-full bg-lblue flex items-center justify-center text-white font-semibold text-sm flex-shrink-0">
2026-01-21 17:48:14 +01:00
{getInitials(trajet.chauffeur.nom, trajet.chauffeur.prenom)}
</div>
2026-01-22 19:25:25 +01:00
<div className="flex-1 min-w-0">
<div className="text-sm sm:text-base font-semibold text-gray-900 truncate">
2026-01-21 17:48:14 +01:00
{trajet.chauffeur.prenom} {trajet.chauffeur.nom}
</div>
2026-01-22 19:25:25 +01:00
<a href={`tel:${trajet.chauffeur.telephone}`} className="text-xs sm:text-sm text-gray-500 hover:text-lblue transition-colors break-all">
{trajet.chauffeur.telephone}
</a>
2026-01-21 17:48:14 +01:00
</div>
</div>
</div>
) : (
<div>
2026-01-22 19:25:25 +01:00
<label className="text-xs sm:text-sm font-medium text-gray-500 mb-2 block">Chauffeur</label>
<div className="p-3 sm:p-4 bg-orange-50 rounded-lg border border-orange-200">
2026-01-21 17:48:14 +01:00
<div className="flex items-center gap-2 text-orange-700">
2026-01-22 19:25:25 +01:00
<svg className="w-4 h-4 sm:w-5 sm:h-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2026-01-21 17:48:14 +01:00
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
</svg>
2026-01-22 19:25:25 +01:00
<span className="text-xs sm:text-sm font-medium">Aucun chauffeur assigné</span>
2026-01-21 17:48:14 +01:00
</div>
</div>
</div>
)}
{/* Date et heure */}
2026-01-22 19:25:25 +01:00
<div className="grid grid-cols-2 gap-3 sm:gap-4">
2026-01-21 17:48:14 +01:00
<div>
2026-01-22 19:25:25 +01:00
<label className="text-xs sm:text-sm font-medium text-gray-500 mb-2 block">Date</label>
<div className="flex items-center gap-2 p-2.5 sm:p-3 bg-gray-50 rounded-lg border border-gray-200">
<svg className="w-4 h-4 sm:w-5 sm:h-5 text-gray-400 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2026-01-21 17:48:14 +01:00
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
</svg>
2026-01-22 19:25:25 +01:00
<span className="text-xs sm:text-sm font-medium text-gray-900 truncate">{formatDate(trajet.date)}</span>
2026-01-21 17:48:14 +01:00
</div>
</div>
<div>
2026-01-22 19:25:25 +01:00
<label className="text-xs sm:text-sm font-medium text-gray-500 mb-2 block">Heure</label>
<div className="flex items-center gap-2 p-2.5 sm:p-3 bg-gray-50 rounded-lg border border-gray-200">
<svg className="w-4 h-4 sm:w-5 sm:h-5 text-gray-400 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
2026-01-21 17:48:14 +01:00
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
2026-01-22 19:25:25 +01:00
<span className="text-xs sm:text-sm font-medium text-gray-900">{formatTime(trajet.date)}</span>
2026-01-21 17:48:14 +01:00
</div>
</div>
</div>
{/* Adresses */}
<div>
2026-01-22 19:25:25 +01:00
<label className="text-xs sm:text-sm font-medium text-gray-500 mb-2 block">Adresse de départ</label>
<div className="p-3 sm:p-4 bg-gray-50 rounded-lg border border-gray-200">
<div className="flex items-start gap-2 mb-3">
<div className="w-5 h-5 sm:w-6 sm:h-6 rounded-full bg-lgreen flex items-center justify-center text-white text-xs font-bold mt-0.5 flex-shrink-0">
2026-01-21 17:48:14 +01:00
A
</div>
2026-01-22 19:25:25 +01:00
<span className="text-xs sm:text-sm text-gray-900 flex-1 break-words">{trajet.adresseDepart}</span>
</div>
<div className="flex flex-wrap gap-2 mt-2 pt-2 border-t border-gray-200">
<button
onClick={() => handleCopyAddress(trajet.adresseDepart)}
className="flex items-center gap-1.5 px-3 py-2 text-xs font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-100 rounded-md transition-colors active:bg-gray-200"
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
</svg>
Copier
</button>
2026-01-21 17:48:14 +01:00
</div>
</div>
</div>
<div>
2026-01-22 19:25:25 +01:00
<label className="text-xs sm:text-sm font-medium text-gray-500 mb-2 block">Adresse d'arrivée</label>
<div className="p-3 sm:p-4 bg-gray-50 rounded-lg border border-gray-200">
<div className="flex items-start gap-2 mb-3">
<div className="w-5 h-5 sm:w-6 sm:h-6 rounded-full bg-lblue flex items-center justify-center text-white text-xs font-bold mt-0.5 flex-shrink-0">
2026-01-21 17:48:14 +01:00
B
</div>
2026-01-22 19:25:25 +01:00
<span className="text-xs sm:text-sm text-gray-900 flex-1 break-words">{trajet.adresseArrivee}</span>
</div>
<div className="flex flex-wrap gap-2 mt-2 pt-2 border-t border-gray-200">
<button
onClick={() => handleCopyAddress(trajet.adresseArrivee)}
className="flex items-center gap-1.5 px-3 py-2 text-xs font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-100 rounded-md transition-colors active:bg-gray-200"
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
</svg>
Copier
</button>
<button
onClick={handleOpenRoute}
className="flex items-center gap-1.5 px-3 py-2 text-xs font-medium bg-lgreen text-white hover:bg-dgreen rounded-md transition-colors active:bg-dgreen"
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-.553-.894L15 4m0 13V4m0 0L9 7" />
</svg>
Ouvrir l'itinéraire
</button>
2026-01-21 17:48:14 +01:00
</div>
</div>
</div>
2026-01-22 19:25:25 +01:00
{/* Instructions */}
{trajet.instructions && (
<div>
<label className="text-xs sm:text-sm font-medium text-gray-500 mb-2 block">Instructions</label>
<div className="p-3 sm:p-4 bg-gray-50 rounded-lg border border-gray-200">
<p className="text-xs sm:text-sm text-gray-700 whitespace-pre-wrap break-words">{trajet.instructions}</p>
</div>
</div>
)}
2026-01-21 17:48:14 +01:00
{/* Commentaire */}
{trajet.commentaire && (
<div>
2026-01-22 19:25:25 +01:00
<label className="text-xs sm:text-sm font-medium text-gray-500 mb-2 block">Commentaire</label>
<div className="p-3 sm:p-4 bg-gray-50 rounded-lg border border-gray-200">
<p className="text-xs sm:text-sm text-gray-700 whitespace-pre-wrap break-words">{trajet.commentaire}</p>
2026-01-21 17:48:14 +01:00
</div>
</div>
)}
2026-01-22 19:25:25 +01:00
</div>
{/* Colonne droite - Carte */}
<div className="lg:sticky lg:top-0 order-first lg:order-last">
<div className="bg-gray-50 rounded-lg border border-gray-200 overflow-hidden h-[300px] sm:h-[400px] lg:h-[500px]">
<TrajetMap
adresseDepart={trajet.adresseDepart}
adresseArrivee={trajet.adresseArrivee}
adherentNom={`${trajet.adherent.prenom} ${trajet.adherent.nom}`}
/>
</div>
</div>
2026-01-21 17:48:14 +01:00
</div>
</div>
{/* Footer */}
2026-01-22 19:25:25 +01:00
<div className="border-t border-gray-200 px-4 sm:px-6 py-3 sm:py-4 bg-gray-50/50 flex-shrink-0">
<div className="flex flex-col sm:flex-row justify-between gap-2 sm:gap-3">
2026-01-21 17:48:14 +01:00
<button
type="button"
2026-01-21 18:13:35 +01:00
onClick={handleCancelClick}
2026-01-21 17:48:14 +01:00
disabled={loading || trajet.statut === 'Validé' || trajet.statut === 'Terminé' || trajet.statut === 'Annulé'}
2026-01-22 19:25:25 +01:00
className="px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium text-red-600 hover:text-red-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2 active:bg-red-50 rounded-lg"
2026-01-21 17:48:14 +01:00
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
2026-01-22 19:25:25 +01:00
<span className="hidden sm:inline">{trajet.statut === 'Annulé' ? 'Trajet annulé' : 'Annuler le trajet'}</span>
<span className="sm:hidden">{trajet.statut === 'Annulé' ? 'Annulé' : 'Annuler'}</span>
2026-01-21 17:48:14 +01:00
</button>
2026-01-22 19:25:25 +01:00
<div className="flex flex-wrap gap-2 sm:gap-3 justify-end">
2026-01-21 17:48:14 +01:00
<button
type="button"
onClick={() => setShowEditForm(true)}
2026-01-21 18:13:35 +01:00
disabled={trajet.statut === 'Validé' || trajet.statut === 'Terminé' || trajet.statut === 'Annulé'}
2026-01-22 19:25:25 +01:00
className="px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium text-gray-700 hover:text-gray-900 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 active:bg-gray-100 rounded-lg"
2026-01-21 17:48:14 +01:00
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
</svg>
2026-01-22 19:25:25 +01:00
<span className="hidden sm:inline">Modifier</span>
<span className="sm:hidden">Modif.</span>
2026-01-21 17:48:14 +01:00
</button>
2026-01-21 18:13:35 +01:00
<button
type="button"
onClick={handleArchiveClick}
disabled={loading}
2026-01-22 19:25:25 +01:00
className="px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium text-orange-600 hover:text-orange-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 active:bg-orange-50 rounded-lg"
2026-01-21 18:13:35 +01:00
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4" />
</svg>
2026-01-22 19:25:25 +01:00
<span className="hidden sm:inline">Archiver</span>
<span className="sm:hidden">Arch.</span>
2026-01-21 18:13:35 +01:00
</button>
2026-01-21 17:48:14 +01:00
{trajet.chauffeur && trajet.statut === 'Planifié' && (
<button
type="button"
onClick={() => setShowValidationModal(true)}
2026-01-22 19:25:25 +01:00
className="px-4 sm:px-6 py-2 bg-lgreen text-white text-xs sm:text-sm font-medium rounded-lg hover:bg-dgreen transition-colors flex items-center gap-2 active:bg-dgreen"
2026-01-21 17:48:14 +01:00
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" />
</svg>
2026-01-22 19:25:25 +01:00
<span className="hidden sm:inline">Valider le trajet</span>
<span className="sm:hidden">Valider</span>
2026-01-21 17:48:14 +01:00
</button>
)}
</div>
</div>
</div>
2026-01-21 18:13:35 +01:00
<ConfirmModal
isOpen={showCancelConfirm}
title="Annuler le trajet"
message="Êtes-vous sûr de vouloir annuler ce trajet ?"
confirmText="Annuler le trajet"
cancelText="Retour"
confirmColor="danger"
onConfirm={handleCancel}
onCancel={() => setShowCancelConfirm(false)}
/>
<ConfirmModal
isOpen={showArchiveConfirm}
title="Archiver le trajet"
message="Êtes-vous sûr de vouloir archiver ce trajet ? Il ne sera plus visible dans le calendrier."
confirmText="Archiver"
cancelText="Annuler"
confirmColor="warning"
onConfirm={handleArchive}
onCancel={() => setShowArchiveConfirm(false)}
/>
2026-01-21 17:48:14 +01:00
</div>
</div>
);
}