<script setup lang="ts">
import { useLoader } from '@/stores/loader'
import { storeToRefs } from 'pinia'
import profile from '@/components/Profile.vue'
import { useTreeDataStore } from '@/stores/tree-data'
const { currentPath } = storeToRefs(useTreeDataStore())
const { getFolder } = useTreeDataStore()
const loaderStore = useLoader()
const { loader } = storeToRefs(loaderStore)
</script>

<template>
  <q-layout view="hHh lpR fFf">
    <q-header class="bg-white text-black" bordered>
      <q-toolbar class="q-py-sm">
        <q-img
          class="pointer"
          src="@/assets/logo.png"
          spinner-color="white"
          style="height: 32px; max-width: 32px"
          @click="
            () => {
              currentPath = ''
              getFolder(currentPath)
            }
          "
        />
        <div
          class="column q-px-md pointer"
          id="app-toolbar-title"
          @click="
            () => {
              currentPath = ''
              getFolder(currentPath)
            }
          "
        >
          <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>
