Added Chat Page
This commit is contained in:
@@ -4,6 +4,7 @@ import { useState, useEffect } from 'react';
|
||||
import { DndContext, DragEndEvent, DragOverlay, DragStartEvent, useDraggable, useDroppable } from '@dnd-kit/core';
|
||||
import { CSS } from '@dnd-kit/utilities';
|
||||
import TrajetDetailModal from './TrajetDetailModal';
|
||||
import { useNotification } from './NotificationProvider';
|
||||
|
||||
interface Trajet {
|
||||
id: string;
|
||||
@@ -152,6 +153,7 @@ function DroppableDayCell({
|
||||
}
|
||||
|
||||
export default function CalendrierTrajets({ refreshTrigger }: CalendrierTrajetsProps) {
|
||||
const { showNotification } = useNotification();
|
||||
const [trajets, setTrajets] = useState<Trajet[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [currentDate, setCurrentDate] = useState(new Date());
|
||||
@@ -308,15 +310,21 @@ export default function CalendrierTrajets({ refreshTrigger }: CalendrierTrajetsP
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const targetDateFormatted = new Date(newDate).toLocaleDateString('fr-FR', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
});
|
||||
showNotification('success', `Trajet déplacé vers le ${targetDateFormatted}`);
|
||||
// Utiliser fetchTrajets sans loading pour éviter de vider les trajets pendant le chargement
|
||||
await fetchTrajets(false);
|
||||
} else {
|
||||
const error = await response.json();
|
||||
alert(error.error || 'Erreur lors du déplacement du trajet');
|
||||
showNotification('error', error.error || 'Erreur lors du déplacement du trajet');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Erreur lors du déplacement:', error);
|
||||
alert('Erreur lors du déplacement du trajet');
|
||||
showNotification('error', 'Erreur lors du déplacement du trajet');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user