[#4] event url is now stored and reused when updating event to prevent duplication

This commit is contained in:
Camille Moussu
2025-08-25 09:47:43 +02:00
parent 4e31b2666c
commit 684fd82027
5 changed files with 39 additions and 33 deletions
+16 -20
View File
@@ -1,28 +1,24 @@
import { api } from "../../utils/apiUtils";
import { Calendars } from "../Calendars/CalendarTypes";
import { CalendarEvent } from "./EventsTypes";
import { calendarEventToJCal } from "./eventUtils";
export async function putEvent(cal: Calendars, event: CalendarEvent) {
const response = await api(
`dav/calendars/${cal.id}/${event.uid.split("/")[0]}.isc`,
{
method: "PUT",
body: JSON.stringify(calendarEventToJCal(event)),
headers: {
"content-type": "text/calendar; charset=utf-8",
},
}
).json();
return response;
export async function putEvent(event: CalendarEvent) {
const response = await api(`dav${event.URL}`, {
method: "PUT",
body: JSON.stringify(calendarEventToJCal(event)),
headers: {
"content-type": "text/calendar; charset=utf-8",
},
});
if (response.status === 201) {
console.log("PUT :", response.url);
}
return await response.json();
}
export async function deleteEvent(calId: string, eventId: string) {
const response = await api(
`dav/calendars/${calId}/${eventId.split("/")[0]}.isc`,
{
method: "DELETE",
}
).json();
export async function deleteEvent(eventURL: string) {
const response = await api(eventURL, {
method: "DELETE",
}).json();
return response;
}