From 1c0c4948527a0798576c4406865ee4b29c792fab Mon Sep 17 00:00:00 2001 From: Alma Date: Sun, 13 Apr 2025 17:33:26 +0200 Subject: [PATCH] calendar 37 --- components/calendar/calendar-client.tsx | 47 +++++++++++++------------ 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/components/calendar/calendar-client.tsx b/components/calendar/calendar-client.tsx index 398df69d..3a6933c2 100644 --- a/components/calendar/calendar-client.tsx +++ b/components/calendar/calendar-client.tsx @@ -743,35 +743,23 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend const handleEventSubmit = async () => { try { - // Log the current state before validation - console.log("Current state before submission:", { - selectedCalendarId, - eventForm, - calendars - }); - - if (!eventForm.title || !eventForm.start || !eventForm.end || !selectedCalendarId) { + // Validate required fields including calendar + if (!eventForm.title || !eventForm.start || !eventForm.end || !eventForm.calendarId) { console.log("Form validation failed:", { title: eventForm.title, start: eventForm.start, end: eventForm.end, - selectedCalendarId, - calendars: calendars.map(c => ({ id: c.id, name: c.name })) + calendarId: eventForm.calendarId }); - setError("Veuillez remplir tous les champs obligatoires"); + setError("Veuillez remplir tous les champs obligatoires et sélectionner un calendrier"); return; } setLoading(true); - // Ensure we're using the selected calendar ID const eventData = { - title: eventForm.title, - description: eventForm.description, + ...eventForm, start: new Date(eventForm.start).toISOString(), end: new Date(eventForm.end).toISOString(), - allDay: eventForm.allDay, - location: eventForm.location, - calendarId: selectedCalendarId, userId }; @@ -987,6 +975,15 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend } }; + // Update the date handlers to maintain consistent time format + const formatTimeForInput = (date: Date) => { + return date.toLocaleTimeString('fr-FR', { + hour: '2-digit', + minute: '2-digit', + hour12: false + }); + }; + return (
@@ -1196,7 +1193,7 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend end: "", allDay: false, location: null, - calendarId: selectedCalendarId + calendarId: selectedCalendarId || calendars[0]?.id }); setSelectedEvent(null); setError(null); @@ -1234,9 +1231,15 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend
{ const [hours, minutes] = e.target.value.split(':'); const date = getDateFromString(eventForm.start); @@ -1297,7 +1300,7 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend { const [hours, minutes] = e.target.value.split(':'); const date = getDateFromString(eventForm.end);