<script setup lang="ts">
import { useMediaLibraryStore } from "@/stores/mediaLibrary";
import * as log from "loglevel";
import { onMounted } from "vue";

log.debug("MediaLibraryView created");

const props = defineProps<{
  mediaLibraryPageSlug: string;
}>();

const mediaLibraryStore = useMediaLibraryStore();

onMounted(async () => {
  log.debug("MediaLibraryView mounted", props.mediaLibraryPageSlug);

  try {
    await mediaLibraryStore.loadMediaLibraryPage(props.mediaLibraryPageSlug);
  } catch (error) {
    log.error(error);
  }
});
</script>

<template>
  <div class="bg-gray-200">
    <nav class="px-6 py-4 border-b bg-white">
      <ul
        v-if="mediaLibraryStore.mediaLibraryPage"
        class="overflow-auto whitespace-nowrap scrollbar"
      >
        <li class="lg:ml-12 inline-block">
          <router-link :to="mediaLibraryStore.mediaLibraryPage.frontend_url">
            Übersicht
          </router-link>
        </li>
        <li class="ml-6 lg:ml-12 inline-block">
          <router-link
            :to="`${mediaLibraryStore.mediaLibraryPage.frontend_url}/category`"
          >
            Handlungsfelder
          </router-link>
        </li>
        <li class="ml-6 lg:ml-12 inline-block">Allgemeines zu Versicherungen</li>
        <li class="ml-6 lg:ml-12 inline-block">Lernmedien</li>
        <li class="ml-6 lg:ml-12 inline-block">
          <a href="https://www.vbv.ch/de/der-vbv/lernen-lehren/lexikon">Lexikon</a>
        </li>
      </ul>
    </nav>
    <main>
      <router-view></router-view>
    </main>
  </div>
</template>

<style scoped>
.scrollbar::-webkit-scrollbar {
  display: none;
}
</style>
