98 implement anonymized DTO events

This commit is contained in:
survellow
2023-12-12 23:40:43 +01:00
parent e8f29941a1
commit 9956261eab
7 changed files with 263 additions and 23 deletions

View File

@@ -1,4 +1,4 @@
import { Event } from "../model/event.ts";
import { AnonymizedEventDTO } from "../model/event.ts";
export async function fetchRoom(): Promise<string[]> {
const rooms: string[] = [];
@@ -16,8 +16,8 @@ export async function fetchEventsByRoomAndDuration(
room: string,
from_date: string,
to_date: string,
): Promise<Event[]> {
const events: Event[] = [];
): Promise<AnonymizedEventDTO[]> {
const events: AnonymizedEventDTO[] = [];
await fetch(
"/api/schedule?room=" + room + "&from=" + from_date + "&to=" + to_date,
)
@@ -27,7 +27,7 @@ export async function fetchEventsByRoomAndDuration(
})
.then((eventsResponse) => {
console.log("Response:", eventsResponse);
eventsResponse.forEach((event: Event) => events.push(event));
eventsResponse.forEach((event: AnonymizedEventDTO) => events.push(event));
})
.catch((error) => {
console.log("Error fetching events: ", error);

View File

@@ -52,7 +52,7 @@ async function getOccupation() {
id: index,
start: event.start.replace(/\s\+\d{4}\s\w+$/, "").replace(" ", "T"),
end: event.end.replace(/\s\+\d{4}\s\w+$/, "").replace(" ", "T"),
showFree: event.name.toLowerCase().includes("zur freien verfügung"),
showFree: event.free
};
});

View File

@@ -14,3 +14,14 @@ export class Event {
public week: string,
) {}
}
export class AnonymizedEventDTO {
constructor(
public day: string,
public week: string,
public start: string,
public end: string,
public rooms: string,
public free: boolean
) {}
}