wrbapp/frontend/pages/calendar.vue

56 lines
1.3 KiB
Vue
Raw Normal View History

2022-09-15 19:15:07 +02:00
<template>
2023-03-20 11:23:46 +01:00
<div class="flex flex-col gap-5 mx-auto p-2 w-full max-w-md">
<div v-if="calendarStore.events[0]" class="flex flex-col gap-3">
<div v-for="(event, index) in calendarStore.events" :key="index">
<div class="item container flex flex-col">
<h2 class="">{{ longEventDate(event.date) }}</h2>
<p class="whitespace-pre overflow-x-auto font-bold text-xl">{{ event.description}}</p>
2022-09-27 15:44:44 +02:00
</div>
2023-03-20 11:23:46 +01:00
</div>
</div>
<div class="w-full flex flex-col justify-center items-center" v-else>
<Icon size="2em" name="ion:load-c" class="animate-spin" />
<h2 class="mt-2 font-bold">Loading...</h2>
2022-09-15 19:15:07 +02:00
</div>
2023-03-20 11:23:46 +01:00
</div>
2022-09-16 21:11:44 +02:00
</template>
<script setup>
definePageMeta({
2023-03-20 11:23:46 +01:00
title: 'Agenda'
2022-09-16 21:11:44 +02:00
})
2022-09-27 15:44:44 +02:00
2023-03-20 11:23:46 +01:00
const userStore = useUserStore()
const calendarStore = useCalendarStore()
2022-09-27 15:44:44 +02:00
onMounted(() => {
2023-03-20 11:23:46 +01:00
getEvents()
2022-09-27 15:44:44 +02:00
})
2023-03-20 11:23:46 +01:00
const getEvents = () => {
if (userStore.userPersons[0]) {
const groups = [...new Set(userStore.userPersons.map(a => a.groups.join()).join().split(','))]
calendarStore.getEvents(groups)
} else {
setTimeout(() => { getEvents() }, 50)
}
}
2022-09-27 15:44:44 +02:00
const longEventDate = (eventDate) => {
const date = new Date(eventDate)
return date.toLocaleString('nl-NL', {
2023-03-20 11:23:46 +01:00
weekday: 'short',
day: 'numeric',
year: 'numeric',
month: 'long',
hour: 'numeric',
minute: 'numeric'
}
2022-09-27 15:44:44 +02:00
)}
2023-01-22 15:04:12 +01:00
</script>