<script setup>
import {useUserStore} from "@/pinia/user";
import {onBeforeMount} from "vue";
import {useRoute} from "vue-router";

const userStore = useUserStore();
const route = useRoute();
onBeforeMount(async () => {
  const user = await userStore.getUser();
  if (!user && !["/#/login", "/#/register"].includes(route.fullPath)) {
    location.href = ('/#/login');
  }
})
</script>

<template>
  <div id="app-layout">
    <slot v-if="userStore.user"></slot>
  </div>
</template>

<style scoped lang="scss">
#app-layout {
  padding: 1em 2em;
  height: calc(100vh - var(--header-height));
}
</style>