<script setup>
import { useRouter} from "vue-router";
import { ref } from 'vue';

const router = useRouter();
const departmentId = ref(router.currentRoute.value.params.departmentId);

const tabs = [
  { name: 'Opret ny', path: '/admin/' + departmentId.value + '/modules/pos' },
  { name: 'Transaktionshistorik', path: '/admin/' + departmentId.value + '/modules/pos/orders' }
];

// Get the current path
const currentPath = ref(router.currentRoute.value.path);

// Get the index of the active tab
const activeTab = tabs.findIndex(tab => tab.path === currentPath.value);

// Change the tab
const changeTab = (index) => {
  router.push(tabs[index].path);
};
</script>

<template>
  <div class="tabs is-right">
    <ul>
      <li v-for="(tab, index) in tabs" :key="index" :class="{'is-active': activeTab === index}" @click="changeTab(index)">
        <a>{{ tab.name }}</a>
      </li>
    </ul>
  </div>
</template>

<style scoped>

</style>