<script lang="ts" setup>
import { Icon } from '@iconify/vue'
import { ref } from 'vue'

import type { Team } from './types'

const { teams } = defineProps<{
  teams: Team[]
}>()

const activeTeam = ref<Team>(teams[0])
</script>

<template>
  <UiSidebarMenu>
    <UiSidebarMenuItem>
      <UiSidebarMenuButton size="lg" class="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground">
        <div
          class="flex items-center justify-center rounded-lg aspect-square size-8 bg-sidebar-primary text-sidebar-primary-foreground"
        >
          <component :is="activeTeam.logo" v-if="typeof activeTeam.logo === 'function'" class="size-4" />
          <Icon v-else :icon="activeTeam.logo" class="size-4" />
        </div>
        <div class="grid flex-1 text-sm leading-tight">
          <span class="font-semibold truncate">{{ activeTeam.name }}</span>
          <span class="text-xs truncate text-muted-foreground">{{ activeTeam.plan }}</span>
        </div>
      </UiSidebarMenuButton>
    </UiSidebarMenuItem>
  </UiSidebarMenu>
</template>
