calendar 37
This commit is contained in:
parent
5eff93a394
commit
1c0c494852
@ -743,35 +743,23 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend
|
|||||||
|
|
||||||
const handleEventSubmit = async () => {
|
const handleEventSubmit = async () => {
|
||||||
try {
|
try {
|
||||||
// Log the current state before validation
|
// Validate required fields including calendar
|
||||||
console.log("Current state before submission:", {
|
if (!eventForm.title || !eventForm.start || !eventForm.end || !eventForm.calendarId) {
|
||||||
selectedCalendarId,
|
|
||||||
eventForm,
|
|
||||||
calendars
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!eventForm.title || !eventForm.start || !eventForm.end || !selectedCalendarId) {
|
|
||||||
console.log("Form validation failed:", {
|
console.log("Form validation failed:", {
|
||||||
title: eventForm.title,
|
title: eventForm.title,
|
||||||
start: eventForm.start,
|
start: eventForm.start,
|
||||||
end: eventForm.end,
|
end: eventForm.end,
|
||||||
selectedCalendarId,
|
calendarId: eventForm.calendarId
|
||||||
calendars: calendars.map(c => ({ id: c.id, name: c.name }))
|
|
||||||
});
|
});
|
||||||
setError("Veuillez remplir tous les champs obligatoires");
|
setError("Veuillez remplir tous les champs obligatoires et sélectionner un calendrier");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
// Ensure we're using the selected calendar ID
|
|
||||||
const eventData = {
|
const eventData = {
|
||||||
title: eventForm.title,
|
...eventForm,
|
||||||
description: eventForm.description,
|
|
||||||
start: new Date(eventForm.start).toISOString(),
|
start: new Date(eventForm.start).toISOString(),
|
||||||
end: new Date(eventForm.end).toISOString(),
|
end: new Date(eventForm.end).toISOString(),
|
||||||
allDay: eventForm.allDay,
|
|
||||||
location: eventForm.location,
|
|
||||||
calendarId: selectedCalendarId,
|
|
||||||
userId
|
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 (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<Card className="p-4">
|
<Card className="p-4">
|
||||||
@ -1196,7 +1193,7 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend
|
|||||||
end: "",
|
end: "",
|
||||||
allDay: false,
|
allDay: false,
|
||||||
location: null,
|
location: null,
|
||||||
calendarId: selectedCalendarId
|
calendarId: selectedCalendarId || calendars[0]?.id
|
||||||
});
|
});
|
||||||
setSelectedEvent(null);
|
setSelectedEvent(null);
|
||||||
setError(null);
|
setError(null);
|
||||||
@ -1234,9 +1231,15 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend
|
|||||||
<button
|
<button
|
||||||
key={cal.id}
|
key={cal.id}
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setSelectedCalendarId(cal.id)}
|
onClick={() => {
|
||||||
|
console.log('Selecting calendar:', cal.id);
|
||||||
|
setEventForm(prev => ({
|
||||||
|
...prev,
|
||||||
|
calendarId: cal.id
|
||||||
|
}));
|
||||||
|
}}
|
||||||
className={`flex items-center gap-2 px-3 py-2 rounded-md border transition-all ${
|
className={`flex items-center gap-2 px-3 py-2 rounded-md border transition-all ${
|
||||||
cal.id === selectedCalendarId
|
eventForm.calendarId === cal.id
|
||||||
? 'border-primary bg-primary/5'
|
? 'border-primary bg-primary/5'
|
||||||
: 'border-gray-200 hover:border-gray-300'
|
: 'border-gray-200 hover:border-gray-300'
|
||||||
}`}
|
}`}
|
||||||
@ -1268,7 +1271,7 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend
|
|||||||
</div>
|
</div>
|
||||||
<Input
|
<Input
|
||||||
type="time"
|
type="time"
|
||||||
value={eventForm.start ? new Date(eventForm.start).toLocaleTimeString('fr-FR', { hour: '2-digit', minute: '2-digit' }) : ''}
|
value={eventForm.start ? formatTimeForInput(new Date(eventForm.start)) : ''}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const [hours, minutes] = e.target.value.split(':');
|
const [hours, minutes] = e.target.value.split(':');
|
||||||
const date = getDateFromString(eventForm.start);
|
const date = getDateFromString(eventForm.start);
|
||||||
@ -1297,7 +1300,7 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend
|
|||||||
</div>
|
</div>
|
||||||
<Input
|
<Input
|
||||||
type="time"
|
type="time"
|
||||||
value={eventForm.end ? new Date(eventForm.end).toLocaleTimeString('fr-FR', { hour: '2-digit', minute: '2-digit' }) : ''}
|
value={eventForm.end ? formatTimeForInput(new Date(eventForm.end)) : ''}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const [hours, minutes] = e.target.value.split(':');
|
const [hours, minutes] = e.target.value.split(':');
|
||||||
const date = getDateFromString(eventForm.end);
|
const date = getDateFromString(eventForm.end);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user