<template>
  <SidebarLayout>
    <template #sidebar>
      <SidebarTemplate
        mainTitle="Mein Account"
        :topTitle="config.app_name_overwrite || 'FF Admin'"
        :showTopList="isOwner"
      >
        <template v-if="isOwner" #topList>
          <RoutingLink
            title="Administration"
            :link="{ name: 'account-administration' }"
            :active="activeRouteName == 'account-administration'"
          />
          <RoutingLink
            title="Versions-Verwaltung"
            :link="{ name: 'account-version' }"
            :active="activeRouteName == 'account-version'"
          />
        </template>
        <template #list>
          <RoutingLink title="Mein Account" :link="{ name: 'account-me' }" :active="activeRouteName == 'account-me'" />
          <RoutingLink
            title="Anmeldedaten"
            :link="{ name: 'account-logindata' }"
            :active="activeRouteName == 'account-logindata'"
          />
          <RoutingLink
            title="Meine Berechtigungen"
            :link="{ name: 'account-permission' }"
            :active="activeRouteName == 'account-permission'"
          />
        </template>
      </SidebarTemplate>
    </template>
    <template #main>
      <RouterView />
    </template>
  </SidebarLayout>
</template>

<script setup lang="ts">
import { defineComponent } from "vue";
import { mapState, mapActions } from "pinia";
import SidebarLayout from "@/layouts/Sidebar.vue";
import SidebarTemplate from "@/templates/Sidebar.vue";
import RoutingLink from "@/components/admin/RoutingLink.vue";
import { RouterView } from "vue-router";
import { useAbilityStore } from "@/stores/ability";
import { config } from "@/config";
</script>

<script lang="ts">
export default defineComponent({
  computed: {
    ...mapState(useAbilityStore, ["isOwner"]),
    activeRouteName() {
      return this.$route.name;
    },
  },
});
</script>
