Added Chat Page
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user