mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-04 02:39:14 +02:00
fixed merge issue with main
This commit is contained in:
36
frontend/src/api/fetchRoom.ts
Normal file
36
frontend/src/api/fetchRoom.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import {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 fetchEventsByRoomAndDuration(
|
||||
room: string,
|
||||
from_date: string,
|
||||
to_date: string,
|
||||
): Promise<Event[]> {
|
||||
const events: Event[] = [];
|
||||
await fetch("/api/schedule?room=" + room + "&from=" + from_date + "&to=" + to_date)
|
||||
.then((response) => {
|
||||
console.log(response);
|
||||
return response.json();
|
||||
})
|
||||
.then((eventsResponse) => {
|
||||
console.log("Response:", eventsResponse);
|
||||
eventsResponse.forEach((event: Event) =>
|
||||
events.push(event));
|
||||
}).catch((error) => {
|
||||
console.log("Error fetching events: ", error);
|
||||
return null;
|
||||
})
|
||||
console.log("occupations: ", events);
|
||||
return events;
|
||||
}
|
Reference in New Issue
Block a user