Fix: Cancel button functionality and live updates in booking management
- Add confirmation modal for booking cancellations - Implement proper error handling and success messages - Fix live updates for booking status changes - Add manual refetch to ensure immediate UI updates - Auto-delete past availability slots on list access - Add manual cleanup function for past slots - Improve user experience with instant feedback
This commit is contained in:
@@ -42,6 +42,9 @@ export function AdminAvailability() {
|
||||
const { mutate: removeSlot } = useMutation(
|
||||
queryClient.availability.remove.mutationOptions()
|
||||
);
|
||||
const { mutate: cleanupPastSlots } = useMutation(
|
||||
queryClient.availability.cleanupPastSlots.mutationOptions()
|
||||
);
|
||||
|
||||
// Auto-update duration when treatment is selected
|
||||
useEffect(() => {
|
||||
@@ -280,6 +283,41 @@ export function AdminAvailability() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Cleanup Button */}
|
||||
<div className="bg-white rounded-lg shadow p-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h3 className="text-lg font-medium text-gray-900">Bereinigung</h3>
|
||||
<p className="text-sm text-gray-600">Vergangene Slots automatisch löschen</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => {
|
||||
const sessionId = localStorage.getItem("sessionId") || "";
|
||||
if (!sessionId) {
|
||||
setErrorMsg("Nicht eingeloggt. Bitte als Inhaber anmelden.");
|
||||
return;
|
||||
}
|
||||
|
||||
cleanupPastSlots(
|
||||
{ sessionId },
|
||||
{
|
||||
onSuccess: (result: any) => {
|
||||
setSuccessMsg(result.message || "Bereinigung abgeschlossen.");
|
||||
refetchSlots();
|
||||
},
|
||||
onError: (err: any) => {
|
||||
setErrorMsg(err?.message || "Fehler bei der Bereinigung.");
|
||||
}
|
||||
}
|
||||
);
|
||||
}}
|
||||
className="px-4 py-2 bg-orange-600 text-white rounded-md hover:bg-orange-700 transition-colors"
|
||||
>
|
||||
Vergangene Slots löschen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* All Slots List */}
|
||||
<div className="bg-white rounded-lg shadow">
|
||||
<div className="p-4 border-b">
|
||||
|
Reference in New Issue
Block a user