Fix: Live updates in availability management
- Add manual refetch calls after slot creation/deletion - Ensure availability list updates immediately after changes - Fix issue where slots didn't appear in list after adding - Improve user experience with real-time updates
This commit is contained in:
@@ -10,7 +10,7 @@ export function AdminAvailability() {
|
|||||||
const [selectedTreatmentId, setSelectedTreatmentId] = useState<string>("");
|
const [selectedTreatmentId, setSelectedTreatmentId] = useState<string>("");
|
||||||
const [slotType, setSlotType] = useState<"treatment" | "manual">("treatment");
|
const [slotType, setSlotType] = useState<"treatment" | "manual">("treatment");
|
||||||
|
|
||||||
const { data: allSlots } = useQuery(
|
const { data: allSlots, refetch: refetchSlots } = useQuery(
|
||||||
queryClient.availability.live.list.experimental_liveOptions()
|
queryClient.availability.live.list.experimental_liveOptions()
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -90,6 +90,9 @@ export function AdminAvailability() {
|
|||||||
: `Manueller Slot (${duration} Min)`;
|
: `Manueller Slot (${duration} Min)`;
|
||||||
setSuccessMsg(`${slotDescription} angelegt.`);
|
setSuccessMsg(`${slotDescription} angelegt.`);
|
||||||
|
|
||||||
|
// Manually refetch slots to ensure live updates
|
||||||
|
refetchSlots();
|
||||||
|
|
||||||
// advance time by the duration of the slot
|
// advance time by the duration of the slot
|
||||||
const [hStr, mStr] = time.split(":");
|
const [hStr, mStr] = time.split(":");
|
||||||
let h = parseInt(hStr, 10);
|
let h = parseInt(hStr, 10);
|
||||||
@@ -337,6 +340,8 @@ export function AdminAvailability() {
|
|||||||
{
|
{
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
setSuccessMsg("Slot erfolgreich gelöscht.");
|
setSuccessMsg("Slot erfolgreich gelöscht.");
|
||||||
|
// Manually refetch slots to ensure live updates
|
||||||
|
refetchSlots();
|
||||||
},
|
},
|
||||||
onError: (err: any) => {
|
onError: (err: any) => {
|
||||||
const msg = (err && (err.message || (err as any).toString())) || "Fehler beim Löschen des Slots.";
|
const msg = (err && (err.message || (err as any).toString())) || "Fehler beim Löschen des Slots.";
|
||||||
|
Reference in New Issue
Block a user