Moved data to api server route

This commit is contained in:
Alexis
2024-05-13 14:41:28 +02:00
parent bb88074215
commit b49b570fe2
15 changed files with 572 additions and 564 deletions

View File

@@ -5,50 +5,11 @@ import { useCalendar } from '@/stores/CalendarStore'
import Calendar from '@/components/calendar/Calendar.vue'
import Sidebar from '@/components/calendar/Sidebar.vue'
import CalendarSearch from '@/components/calendar/search/CalendarSearch.vue'
import { useRoute, useRouter } from 'vue-router'
import { isDigit, isInt, isSignedInt } from '@/utils/Regex'
import { onBeforeMount } from 'vue'
const router = useRouter()
const route = useRoute()
const { defaultDate, selectedDate, jumpToDate } = useCalendar()
const { isAdvancedSearchOpen } = storeToRefs(useCalendar())
// Check whether all the params are good to go before rendering anything
onBeforeMount(() => {
let isInvalid: boolean = false
// If the user already has a selected date from session, jump to it
if (selectedDate) {
jumpToDate(selectedDate)
} else {
// Assign default values if no params exist in URL
if (!route.query.day || typeof route.query.day === 'object' || !isInt(route.query.day)) {
route.query.day = defaultDate.day.toString()
isInvalid = true
}
if (
!route.query.month ||
typeof route.query.month === 'object' ||
!isDigit(route.query.month)
) {
route.query.month = defaultDate.month.toString()
isInvalid = true
}
if (
!route.query.year ||
typeof route.query.year === 'object' ||
!isSignedInt(route.query.year)
) {
route.query.year = defaultDate.year.toString()
isInvalid = true
}
if (isInvalid) {
console.log('replaced')
router.replace({ query: route.query, replace: true })
}
}
useHead({
title: 'Calendar'
})
</script>

View File

@@ -1,3 +1,9 @@
<script lang="ts" setup>
useHead({
title: 'Dashboard'
})
</script>
<template>
<main class="h-full grid place-items-center">
<UiCard class="w-1/3 min-w-72" link="/calendar">