agenda widget mia 2
This commit is contained in:
parent
ebb7bba8ea
commit
0dc78b4c9f
@ -66,10 +66,20 @@ export async function PUT(req: NextRequest) {
|
||||
}
|
||||
|
||||
try {
|
||||
const { id, title, description, start, end, allDay, location, calendarId } = await req.json();
|
||||
const data = await req.json();
|
||||
console.log("Received event update data:", data);
|
||||
|
||||
const { id, title, description, start, end, allDay, location, calendarId } = data;
|
||||
|
||||
// Validation
|
||||
if (!id || !title || !start || !end || !calendarId) {
|
||||
console.log("Validation failed. Missing fields:", {
|
||||
id: !id,
|
||||
title: !title,
|
||||
start: !start,
|
||||
end: !end,
|
||||
calendarId: !calendarId
|
||||
});
|
||||
return NextResponse.json(
|
||||
{ error: "ID, titre, début, fin et calendrier sont requis" },
|
||||
{ status: 400 }
|
||||
@ -91,7 +101,13 @@ export async function PUT(req: NextRequest) {
|
||||
}
|
||||
});
|
||||
|
||||
console.log("Found calendar:", calendar);
|
||||
|
||||
if (!calendar || calendar.events.length === 0) {
|
||||
console.log("Calendar or event not found:", {
|
||||
calendarFound: !!calendar,
|
||||
eventsFound: calendar?.events.length
|
||||
});
|
||||
return NextResponse.json(
|
||||
{ error: "Événement non trouvé ou non autorisé" },
|
||||
{ status: 404 }
|
||||
@ -111,6 +127,7 @@ export async function PUT(req: NextRequest) {
|
||||
},
|
||||
});
|
||||
|
||||
console.log("Updated event:", event);
|
||||
return NextResponse.json(event);
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la mise à jour de l'événement:", error);
|
||||
|
||||
@ -695,7 +695,9 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend
|
||||
...eventForm,
|
||||
start: new Date(eventForm.start).toISOString(),
|
||||
end: new Date(eventForm.end).toISOString(),
|
||||
userId
|
||||
userId,
|
||||
...(selectedEvent ? { id: selectedEvent.id } : {}), // Include ID for updates
|
||||
allDay: eventForm.allDay // Use allDay instead of isAllDay
|
||||
};
|
||||
|
||||
console.log("Submitting event with data:", eventData);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user