2025-03-05 15:36:50 +01:00
|
|
|
<template>
|
|
|
|
<main>
|
|
|
|
<h1>Schedule & Events</h1>
|
|
|
|
<p>
|
|
|
|
Study carefully, we only hold these events once a year.
|
|
|
|
</p>
|
2025-03-07 18:43:24 +01:00
|
|
|
<p v-if="!session">
|
2025-03-07 23:53:57 +01:00
|
|
|
<NuxtLink to="/login">Login</NuxtLink> or <NuxtLink to="/login#create-account">Create an account</NuxtLink>
|
|
|
|
to get notified about updates to the schedule.
|
2025-03-07 18:43:24 +01:00
|
|
|
</p>
|
2025-03-07 23:53:57 +01:00
|
|
|
<p v-else>
|
2025-03-07 18:43:24 +01:00
|
|
|
Check out your <NuxtLink to="/account/settings">Account Setting</NuxtLink> to set up notifications for changes to schedule.
|
2025-03-05 15:36:50 +01:00
|
|
|
</p>
|
|
|
|
<h2>Schedule</h2>
|
|
|
|
<Timetable />
|
|
|
|
<EventsEdit />
|
|
|
|
<h2>Events</h2>
|
|
|
|
<EventCard v-for="event in schedule.events" :event/>
|
|
|
|
<h2>Locations</h2>
|
|
|
|
<ul>
|
|
|
|
<li v-for="location in schedule.locations" :key="location.id">
|
|
|
|
<h3>{{ location.name }}</h3>
|
|
|
|
{{ location.description ?? "No description provided" }}
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</main>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import type { Schedule } from '~/shared/types/schedule';
|
2025-03-07 18:43:24 +01:00
|
|
|
const { data: session } = useAccountSession();
|
2025-03-05 15:36:50 +01:00
|
|
|
|
|
|
|
const schedule = useSchedule();
|
|
|
|
|
|
|
|
await callOnce(async () => {
|
2025-03-07 18:43:24 +01:00
|
|
|
schedule.value = await $fetch("/api/schedule");
|
2025-03-05 15:36:50 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
const source = ref<EventSource | null>(null);
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
console.log("Opening event source")
|
|
|
|
source.value = new EventSource("/api/events");
|
|
|
|
source.value.addEventListener("message", (message) => {
|
|
|
|
console.log("Message", message.data);
|
|
|
|
});
|
|
|
|
source.value.addEventListener("update", (message) => {
|
|
|
|
const updatedSchedule: Schedule = JSON.parse(message.data);
|
|
|
|
console.log("Update", updatedSchedule);
|
|
|
|
schedule.value = updatedSchedule;
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
if (source.value) {
|
|
|
|
console.log("Closing event source")
|
|
|
|
source.value.close();
|
|
|
|
source.value = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|