<script setup lang="ts">
import { storeToRefs } from 'pinia'

import { useLoader } from '@/stores/loader'
import { useSearchDataStore } from '@/stores/searched-data'
import { useFileInfoStore } from '@/stores/file-info-data'
import useStorage from '@/stores/storage'

import profile from '@/components/Profile.vue'

const { isFilePreview } = storeToRefs(useFileInfoStore())
const { isSearch } = storeToRefs(useSearchDataStore())
const { loader } = storeToRefs(useLoader())
const { goto } = useStorage()
</script>

<template>
  <q-layout view="hHh lpR fFf">
    <q-header class="bg-white text-black" bordered>
      <q-toolbar class="q-py-sm q-pr-sm">
        <q-img
          class="pointer"
          src="@/assets/logo-edm.png"
          spinner-color="white"
          style="height: 45px; max-width: 45px"
          @click="() => goto()"
        />
        <div
          class="column q-px-md pointer"
          id="app-toolbar-title"
          @click="
            () => {
              goto()
              isSearch = false
              isFilePreview = false
            }
          "
        >
          <span class="text-body1">ระบบทรัพยากรบุคคล</span>
          <span class="text-caption text-grey">
            จัดเก็บข้อมูลผลการประเมิน
          </span>
        </div>

        <q-space></q-space>
        <profile />
      </q-toolbar>
    </q-header>

    <q-page-container>
      <q-page>
        <router-view :key="$route.fullPath" />
      </q-page>
    </q-page-container>
    <full-loader :visibility="loader" />
  </q-layout>
</template>

<style scoped>
.q-layout {
  background: var(--q-secondary);
}

.pointer {
  cursor: pointer;
}
</style>
