[tab].vue 3.37 KB
<script setup lang="ts">
import { computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useKeycloakStore } from '@/@core/stores/keycloakStore'
import UserBerita from '@/components/beranda/UserBerita.vue'
import UserLib from '@/components/beranda/UserLib.vue'
import UserLog from '@/components/beranda/UserLog.vue'
import UserJadwal from '@/components/beranda/UserJadwal.vue'
import UserRiwayat from '@/components/beranda/UserRiwayat.vue'

import UserKeamanan from '@/views/dstipro/beranda/keamanan/index.vue'
import UserPeta from '@/views/dstipro/beranda/peta/index.vue'
import UserProfile from '@/views/dstipro/beranda/profile/index.vue'
import UserProfileHeader from '@/views/dstipro/beranda/UserProfileHeader.vue'

const keycloakStore = useKeycloakStore()

definePageMeta({
  navActiveLink: 'naputpro-beranda-tab',
  key: 'tab',

})

const route = useRoute('naputpro-beranda-tab')
const router = useRouter()

// Pastikan activeTab bertipe string agar tidak ada error TypeScript
// const activeTab = computed(() => String(route.params.tab))
const activeTab = computed({
  get: () => route.params.tab,
  set: () => route.params.tab,
})

// Semua tab
const tabs = [
  { title: 'Profil', icon: 'ri-user-line', tab: 'profile' },
  { title: 'Keamanan', icon: 'ri-lock-line', tab: 'keamanan' },
  { title: 'Berita', icon: 'ri-news-line', tab: 'berita' },
  { title: 'Riwayat', icon: 'ri-file-history-line', tab: 'riwayat' },
  { title: 'Jadwal', icon: 'ri-calendar-line', tab: 'jadwal' },
  { title: 'Log Absen', icon: 'ri-history-line', tab: 'log' },
  { title: 'Peta', icon: 'ri-history-line', tab: 'peta' },
  
  { title: 'Peminjaman Buku', icon: 'ri-book-line', tab: 'lib' },

]

// Filter tab berdasarkan civitas
const filteredTabs = computed(() =>
  tabs.filter(tab => !(tab.tab === 'riwayat' && keycloakStore.civitas !== 'mahasiswa')),
)

// Fungsi untuk navigasi tab
const navigateTab = (tab: string) => {
  router.push(`/naputpro/beranda/${tab}`)
}
</script>

<template>
  <UserProfileHeader class="mb-5" />
  <!--
    <div class="mb-10">
    <h1>Welcome, {{ keycloakStore.name }}</h1>
    </div>
  -->
  <div>
    <VTabs
      v-model="activeTab"
      class="v-tabs-pill"
    >
      <VTab
        v-for="item in filteredTabs"
        :key="item.icon"
        :value="item.tab"
        :to="{ name: 'naputpro-beranda-tab', params: { tab: item.tab } }"
      >
        <VIcon
          start
          :icon="item.icon"
        />
        {{ item.title }}
      </VTab>
    </VTabs>

    <VWindow
      v-model="activeTab"
      class="mt-5 disable-tab-transition"
      :touch="false"
    >
      <!-- Profile -->
      <VWindowItem value="profile">
        <UserProfile />
      </VWindowItem>

      <!-- Keamanan -->
      <VWindowItem value="keamanan">
        <UserKeamanan />
      </VWindowItem>

      <!-- Berita -->
      <VWindowItem value="berita">
        <UserBerita />
      </VWindowItem>

      <!-- Riwayat -->
      <VWindowItem value="riwayat">
        <UserRiwayat />
      </VWindowItem>

      <!-- Jadwal -->
      <VWindowItem value="jadwal">
        <UserJadwal />
      </VWindowItem>

      <!-- Log Absen -->
      <VWindowItem value="log">
        <UserLog />
      </VWindowItem>

      <!-- Peta UI -->
      <VWindowItem value="peta">
        <UserPeta />
      </VWindowItem>

      <VWindowItem value="lib">
        <UserLib />
      </VWindowItem>
    </vwindow>
  </div>
</template>