This commit is contained in:
Tom Wahl
2023-10-20 15:32:17 +02:00
parent 86f2636681
commit d99a6e594b
28 changed files with 1206 additions and 213 deletions

View File

@@ -0,0 +1,30 @@
import {Module, Event} from "../model/event.ts";
export async function fetchRoom(): Promise<string[]> {
const rooms: string[] = [];
await fetch("/api/rooms")
.then((response) => {
return response.json();
})
.then((roomsResponse) => {
roomsResponse.forEach((room: string) => rooms.push(room));
});
return rooms;
}
export async function fetchEventsByRoomAndWeek(
room: string,
week: string,
): Promise<Event[]> {
const occupations: Event[] = [];
await fetch("/api/schedule/week?room=" + room + "&week=" + week)
.then((response) => {
return response.json();
})
.then((eventsResponse) => {
eventsResponse.forEach((event: Event) =>
occupations.push(new Event(event.Days, event.Week, event.Start, event.End, event.Name, event.EventType, event.Prof, event.Rooms, event.Notes, event.BookedAt, event.Course, event.Semester)),
);
});
return occupations;
}