<template>
  <q-page class="q-pa-md">
    <SettingsTabsHeader />

    <q-banner
      class="bg-grey-2 text-primary"
      inline-actions
      rounded
      style="border: 1px dashed rgba(14, 52, 91, 0.18)"
    >
      Redirecionando para a primeira aba disponível.
    </q-banner>
  </q-page>
</template>

<script setup>
import { onMounted } from "vue";
import { permissionStore } from "src/stores/permission";
import { useRouter } from "vue-router";

import SettingsTabsHeader from "./components/SettingsTabsHeader.vue";

const router = useRouter();

const { getAccess } = permissionStore();

const redirectToFirstAllowedTab = () => {
  if (getAccess("config.user", "view")) {
    router.replace({ name: "SettingsUsersPage" });

    return;
  }

  if (getAccess("config.permission", "view")) {
    router.replace({ name: "SettingsUserTypesPage" });
  }
};

onMounted(() => {
  redirectToFirstAllowedTab();
});
</script>
