<template>
  <ClientOnly>
    <NuxtPage></NuxtPage>
  </ClientOnly>
</template>

<script setup lang="ts">
import type { RouteLocation } from 'vue-router';

// Guard dashboard and redirect to login
useRouter().beforeEach((route: RouteLocation) => {
  guard(route.fullPath);
});

guard(useRoute().fullPath);

function guard(route: string)
{
  if(route.startsWith('/dashboard') && getToken() == null)
  {
    useRouter().push('/');
  }
}

useHead({
  title: 'Kubooboo'
})
</script>