<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/entry.vue'

const { getRouteTitle, getPageAccess } = usePageChecker()

definePageMeta({
  middleware: ['rbac'],
  roles: ['emp|reg'],
  title: 'Tambah Kunjungan',
  contentFrame: 'cf-full-width',
})

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

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

<template>
  <div v-if="hasAccess">
    <Content
      :id="0"
      class-code="emergency"
      sub-class-code="emg"
      form-type="add"
    />
  </div>
  <Error
    v-else
    :status-code="403"
  />
</template>
