mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-04 02:39:14 +02:00
[#10] WIP
This commit is contained in:
30
frontend/src/api/fetchRoom.ts
Normal file
30
frontend/src/api/fetchRoom.ts
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user