Added Chat Page

This commit is contained in:
2026-01-21 18:13:35 +01:00
parent 0ca8ce8b52
commit 3eed79ca93
37 changed files with 3966 additions and 64 deletions

View File

@@ -3,6 +3,7 @@
import { useState, useEffect, useRef } from 'react';
import TrajetMap from './TrajetMap';
import AddressAutocomplete from './AddressAutocomplete';
import { useNotification } from './NotificationProvider';
interface Adherent {
id: string;
@@ -37,6 +38,7 @@ interface TrajetFormProps {
}
export default function TrajetForm({ onClose, onSuccess, trajetToEdit }: TrajetFormProps) {
const { showNotification } = useNotification();
const [loading, setLoading] = useState(false);
const [adherents, setAdherents] = useState<Adherent[]>([]);
const [chauffeurs, setChauffeurs] = useState<Chauffeur[]>([]);
@@ -233,15 +235,19 @@ export default function TrajetForm({ onClose, onSuccess, trajetToEdit }: TrajetF
});
if (response.ok) {
showNotification(
'success',
trajetToEdit ? 'Trajet modifié avec succès' : 'Trajet créé avec succès'
);
onSuccess();
onClose();
} else {
const error = await response.json();
alert(`Erreur: ${error.error || `Erreur lors de la ${trajetToEdit ? 'modification' : 'création'} du trajet`}`);
showNotification('error', error.error || `Erreur lors de la ${trajetToEdit ? 'modification' : 'création'} du trajet`);
}
} catch (error) {
console.error(`Erreur lors de la ${trajetToEdit ? 'modification' : 'création'} du trajet:`, error);
alert(`Erreur lors de la ${trajetToEdit ? 'modification' : 'création'} du trajet`);
showNotification('error', `Erreur lors de la ${trajetToEdit ? 'modification' : 'création'} du trajet`);
} finally {
setLoading(false);
}