diff --git a/components/calendar/calendar-client.tsx b/components/calendar/calendar-client.tsx index ca0043e6..8510f25f 100644 --- a/components/calendar/calendar-client.tsx +++ b/components/calendar/calendar-client.tsx @@ -90,6 +90,8 @@ function CalendarDialog({ open, onClose, onSave, onDelete, initialData }: Calend const [isSubmitting, setIsSubmitting] = useState(false); const [customColorMode, setCustomColorMode] = useState(false); + const isMainCalendar = initialData?.name === "Calendrier principal"; + useEffect(() => { if (open) { setName(initialData?.name || ""); @@ -119,7 +121,11 @@ function CalendarDialog({ open, onClose, onSave, onDelete, initialData }: Calend }; const handleDelete = async () => { - if (!initialData?.id || !onDelete) return; + if (!initialData?.id || !onDelete || isMainCalendar) return; + + if (!confirm("Êtes-vous sûr de vouloir supprimer ce calendrier ? Tous les événements associés seront également supprimés.")) { + return; + } setIsSubmitting(true); try { @@ -160,6 +166,7 @@ function CalendarDialog({ open, onClose, onSave, onDelete, initialData }: Calend onChange={(e) => setName(e.target.value)} placeholder="Nom du calendrier" required + disabled={isMainCalendar} className="rounded-lg border-gray-300 focus:border-indigo-500 focus:ring-indigo-500" /> @@ -245,12 +252,12 @@ function CalendarDialog({ open, onClose, onSave, onDelete, initialData }: Calend
- {initialData?.id && ( + {initialData?.id && !isMainCalendar && ( +
+ + {calendar.name !== "Calendrier principal" && ( + + )} +
))}
);