<script setup>
const auth = useAuthStore()

const selectedTenant = ref(auth.user.tenant_id)


</script>

<template>
  <USelectMenu
    :options="auth.tenants"
    value-attribute="id"
    class="w-40"
    @change="auth.switchTenant(selectedTenant)"
    v-model="selectedTenant"
  >
    <UButton color="gray" variant="ghost" :class="[open && 'bg-gray-50 dark:bg-gray-800']" class="w-full">
      <UAvatar :alt="auth.tenants.find(i => auth.activeTenant === i.id).name" size="md" />

      <span class="truncate text-gray-900 dark:text-white font-semibold">{{auth.tenants.find(i => auth.activeTenant === i.id).name}}</span>
    </UButton>

    <template #option="{option}">
      {{option.name}}
    </template>
  </USelectMenu>
</template>