<script setup>



import GlobalSearch from "~/components/GlobalSearch.vue";
const supabase = useSupabaseClient()
const user = useSupabaseUser()
//console.log(user.value)
const route = useRoute()
const tenants = (await supabase.from("tenants").select()).data


const dataStore = useDataStore()



//console.log(userProfile)







const viewport = useViewport()

watch(viewport.breakpoint, (newBreakpoint, oldBreakpoint) => {
  console.log('Breakpoint updated:', oldBreakpoint, '->', newBreakpoint)
})


dataStore.initializeData()



const linksForBreadcrumbs = ref([])






//const userTenant = ref({})
//if(user) userTenant.value = tenants.find(tenant => tenant.id === user.value.app_metadata.tenant)



useHead({
  meta: [
    { name: 'viewport', content: 'width=device-width, initial-scale=1' }
  ],
  link: [
    { rel: 'icon', href: '/favicon.ico' }
  ],
  htmlAttrs: {
    lang: 'de'
  }
})

useSeoMeta({
  ogSiteName: 'spaces.software',
  twitterCard: 'summary_large_image'
})




const items = [
  [{
    label: user.value ? user.value.email : "",
    slot: 'account',
    disabled: true
  }], [{
    label: 'Externe Geräte',
    icon: 'i-heroicons-cog-8-tooth',
    to: "/settings/externalDevices"
  },{
    label: 'Nummernkreise',
    icon: 'i-heroicons-cog-8-tooth',
    to: "/settings/numberRanges"
  },{
    label: 'Benutzer',
    icon: 'i-heroicons-user-group',
    to: "/settings/users"
  }], /*[{
    label: 'Documentation',
    icon: 'i-heroicons-book-open'
  }, {
    label: 'Changelog',
    icon: 'i-heroicons-megaphone'
  }, {
    label: 'Status',
    icon: 'i-heroicons-signal'
  }],*/ [{
    label: 'Ausloggen',
    icon: 'i-heroicons-arrow-left-on-rectangle',
    click: async () => {
      await supabase.auth.signOut()
      await dataStore.clearStore()
      await router.push("/login")

    }
  }]
]

</script>

<template>

  <NuxtLayout>
    <NuxtPage/>
  </NuxtLayout>
<!--  <UFooter>
    <template #left>
      <p class="text-gray-500 dark:text-gray-400 text-sm">
        Copyright © 2023-{{ new Date().getFullYear() }} <NuxtLink class="hover:underline" to="https://federspiel.tech" target="_blank">
        Federspiel Technolog UG haftungsbeschränkt
      </NuxtLink>
      </p>
    </template>

    <template #right>

    </template>
  </UFooter>-->

  <UNotifications/>
  <VitePwaManifest/>

<!--    <UCard id="page">
      <template #header>
        <div id="menu">
          <router-link
              v-for="link in navLinks"
              :to="link.to"
              class="mr-2"
          >
            <UButton>{{link.label}}</UButton>
          </router-link>
          &lt;!&ndash;<router-link to="/customers" class="mr-2"><UButton>Kunden</UButton></router-link>
          <router-link to="/projects" class="mr-2"><UButton>Projekte</UButton></router-link>
  -
          <router-link to="/receipts" class="mr-2"><UButton>Eingangsrechnungen</UButton></router-link>

          <router-link to="/timetracking" class="mr-2"><UButton>Zeiterfassung</UButton></router-link>
          <router-link to="/products" class="mr-2"><UButton>Artikel</UButton></router-link>
          <router-link to="/documents" class="mr-2"><UButton>Dokumente</UButton></router-link>
          <router-link to="/inventory" class="mr-2"><UButton>Inventar</UButton></router-link>&ndash;&gt;
          <UDropdown :items="userDropdownItems" :popper="{placement: 'bottom-start'}">
            <UButton color="white" label="Benutzer" trailing-icon="i-heroicons-chevron-down-20-solid" />
          </UDropdown>
        </div>
        <UBreadcrumb
            class="my-3"
            :links="linksForBreadcrumbs"
        />
      </template>
      <NuxtPage
          v-if="loaded"
      />
      <div
          v-else
      >
        <UProgress animation="carousel" />
      </div>
    </UCard>-->



</template>

<style>

#logo img{
  height: 15vh;
  width: auto;
}

#contentContainer {
  width: 95vw;
  height: 85vh;
}

.documentList {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  overflow-y: scroll;
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

.documentList::-webkit-scrollbar {
  display: none;
}

.scrollList {
  overflow-y: scroll;
  height: 85vh;
  margin-top: 1em;
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

.scrollList::-webkit-scrollbar {
  display: none;
}


  #page {
    width: 98vw;
    height: 95vh;
    margin:1em;
  }

  .listItem {
    padding: .1em;
    border: 1px solid grey;
    border-radius: 15px;
    margin-top: 1em;
  }
  .listItem:hover {
    border: 1px solid #69c350;
  }


  a:hover {
    color: #69c350
  }
</style>