Fix live test follow-up issues
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useTransition } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Info, Loader2, CheckCircle2 } from "lucide-react";
|
||||
import { format } from "date-fns";
|
||||
import { de } from "date-fns/locale";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { getWorkingDaysOfMonth } from "@/lib/date-utils";
|
||||
import { formatDateKey, getWorkingDaysOfMonth } from "@/lib/date-utils";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { saveNotdienstAvailabilities } from "./actions";
|
||||
|
||||
@@ -23,7 +24,7 @@ interface NotdienstFormProps {
|
||||
targetMonth: number;
|
||||
isLocked: boolean;
|
||||
requiredDaysTotal: number;
|
||||
initialSelectedDates: string[]; // ISO Strings
|
||||
initialSelectedDates: string[];
|
||||
childrenIds: string[];
|
||||
}
|
||||
|
||||
@@ -35,7 +36,8 @@ export function NotdienstForm({
|
||||
initialSelectedDates,
|
||||
childrenIds,
|
||||
}: NotdienstFormProps) {
|
||||
// Lokaler State für die Auswahl. Ein Datum liegt immer als ISO-String vor (z.B. "2026-06-01T00:00:00.000Z")
|
||||
const router = useRouter();
|
||||
// Lokaler State für die Auswahl. Ein Datum liegt als stabiler yyyy-MM-dd-Schlüssel vor.
|
||||
const [selectedDates, setSelectedDates] = useState<Set<string>>(
|
||||
new Set(initialSelectedDates),
|
||||
);
|
||||
@@ -78,7 +80,9 @@ export function NotdienstForm({
|
||||
if (result?.error) {
|
||||
toast.error(result.error);
|
||||
} else {
|
||||
setSelectedDates(new Set(result.dates));
|
||||
toast.success("Verfügbarkeiten erfolgreich gespeichert.");
|
||||
router.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -134,7 +138,7 @@ export function NotdienstForm({
|
||||
</div>
|
||||
<div className="divide-y">
|
||||
{workingDays.map((day) => {
|
||||
const dateStr = day.toISOString();
|
||||
const dateStr = formatDateKey(day);
|
||||
const isSelected = selectedDates.has(dateStr);
|
||||
const isToday = day.getTime() === new Date().setHours(0, 0, 0, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user