[#31]added two function to setup data to be sent and put function

This commit is contained in:
Camille Moussu
2025-07-22 09:50:02 +02:00
parent fd059954f4
commit b1ceebfc7d
12 changed files with 2906 additions and 48 deletions
+25
View File
@@ -0,0 +1,25 @@
import { api } from "../../utils/apiUtils";
import { Calendars } from "../Calendars/CalendarTypes";
import { CalendarEvent } from "./EventsTypes";
import { calendarEventToICal, 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(calendarEventToICal(cal, event)),
headers: {
"content-type": "text/calendar; charset=utf-8",
},
}
).json();
return response;
}
export async function getEvent(calID: string, eventID: string) {
const response = await api
.get(`dav/calendars/${calID}/${eventID}.ics`)
.json();
return response;
}