<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { useAuthStore } from '@/stores/auth'
import { useProjectsStore } from '@/stores/projects'
import { storage } from '@/services/storage'
import { initPrompts } from '@/services/prompts-db'
import LoginView from '@/views/LoginView.vue'
import NewDashboardView from '@/views/NewDashboardView.vue'

const auth = useAuthStore()
const projectsStore = useProjectsStore()

onMounted(async () => {
  await storage.init()
  await initPrompts()
  if (auth.isAuthenticated) {
    projectsStore.fetchProjects()
  }
})
</script>

<template>
  <LoginView v-if="!auth.isAuthenticated" />
  <NewDashboardView v-else />
</template>