<script setup>
const user = useSupabaseUser()
const router = useRouter()
const supabase = useSupabaseClient()
const tenants = (await supabase.from("tenants").select()).data


const userTenant = ref({})
if(user) userTenant.value = tenants.find(tenant => tenant.id === user.value.app_metadata.tenant)
const userDropdownItems = [
    [
      {
        label: user.value ? user.value.email : "Profil",

      },/*{
        label: user ? userTenant.value.name : "",

      }*/
    ],
    [
      {
        label: "Logout",
        click: () => {

          router.push("/login")
        }
      }
    ]
]
</script>

<template>
  <UCard id="page">
    <template #header>
      <div id="menu">
        <router-link to="/tasks" class="mr-2"><UButton>Aufgaben</UButton></router-link>
        <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="/vendorinvoices" 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>
        <UDropdown :items="userDropdownItems" :popper="{placement: 'bottom-start'}">
          <UButton color="white" label="Benutzer" trailing-icon="i-heroicons-chevron-down-20-solid" />
        </UDropdown>
      </div>
    </template>
    <NuxtPage/>
  </UCard>
</template>

<style >

  #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;
  }

</style>