<template>
  <div class="gamemaster__container">
    <TopBar />
    <AdminGameInfoTile />
</div>
</template>

<script setup lang="ts">
import { navigateTo } from '#app'
import { onMounted, onBeforeUnmount } from 'vue'
import useAuth from '@/composables/useAuth'
import useEngine from '@/composables/useEngine'

// ensure user is authenticated
const { authenticateAndLoadUserInfo } = useAuth()
try {
  await authenticateAndLoadUserInfo()
} catch (e) {
  navigateTo('/', { replace: true })
}

const { start: startEngine, stop: stopEngine } = useEngine()
onMounted(() => startEngine())
onBeforeUnmount(() => stopEngine())
</script>

<style lang="scss">
.gamemaster {
  &__container {
    width: 100%;
    height: 100%;
  }
}
</style>