<template>
  <div :key="locale" class="tw-flex tw-flex-col tw-min-h-screen">
    <AppNavbar :modules="modules" />

    <div class="tw-flex-1 tw-flex tw-my-8">
      <RouterView v-if="authStore.steeringUser" />
      <Home v-else :modules="modules" />
    </div>

    <AppFooter />
  </div>
</template>

<script lang="ts" setup>
import AppNavbar from './components/Navbar.vue'
import AppFooter from './components/Footer.vue'
import Home from './Pages/Home.vue'
import { useI18n } from '@/i18n'
import { useAuthStore } from '@/stores/auth'
import { computedIter } from '@/util'

const { locale, t } = useI18n()
const authStore = useAuthStore()

const modules = computedIter(function* () {
  if (authStore.currentUser) {
    yield {
      icon: '/assets/shows.svg',
      slug: 'shows',
      title: t('navigation.shows'),
    }
    yield {
      icon: '/assets/files.svg',
      slug: 'files',
      title: t('navigation.filesPlaylists'),
    }
  }

  if (authStore.isSuperuser) {
    yield {
      icon: '/assets/calendar.svg',
      slug: 'calendar',
      title: t('navigation.calendar'),
    }
  }
})
</script>