<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('/account') && getToken() == null)
  {
    useRouter().push('/');
  }
  if(route === '/' && getToken() != null)
  {
    useRouter().push('/account/inspect/nodes/_all');
  }
}

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