<script setup lang="ts">
// Types & Consts
import type { Permission } from '~/models/role'
import { permissions } from '~/const/page-permission/emergency'

// Helpers
import { usePageChecker } from "~/lib/page-checker"

// Pubs
import Error from '~/components/pub/my-ui/error/error.vue'

// Apps
import Content from '~/components/content/encounter/detail.vue'

const { getRouteTitle, getPageAccess } = usePageChecker()

definePageMeta({
  middleware: ['rbac'],
  roles: ['emp|doc', 'emp|nur', 'emp|reg', 'emp|pha', 'emp|pay', 'emp|mng'],
  title: 'Detail Kunjungan',
  contentFrame: 'cf-full-width',
})

useHead({
  title: () => `${getRouteTitle()}`,
})

// Preps role checking
const roleAccess: Record<string, Permission[]> = permissions['/emergency/encounter/[id]'] || {}
const hasAccess = getPageAccess(roleAccess, 'read')
</script>

<template>
  <div v-if="hasAccess">
    <Content />
  </div>
  <Error v-else :status-code="403" />
</template>
