refactor(role): rename PagePermission to RoleAccesses and fix base model id

Update type name from PagePermission to RoleAccesses across multiple files for consistency
Change mock id value from -1 to 0 in base model to match backend constraints
Enable RBAC middleware and fix patient edit page permissions
This commit is contained in:
Khafid Prayoga
2025-12-08 18:57:35 +07:00
parent 1083bb5384
commit e967ee1cf0
7 changed files with 26 additions and 29 deletions
@@ -1,12 +1,12 @@
<script setup lang="ts">
// import type { PagePermission } from '~/models/role'
import type { RoleAccesses } from '~/models/role'
import Error from '~/components/pub/my-ui/error/error.vue'
// import { PAGE_PERMISSIONS } from '~/lib/page-permission'
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
definePageMeta({
// middleware: ['rbac'],
middleware: ['rbac'],
roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'],
title: 'Daftar Divisi',
title: 'Edit Pasien',
contentFrame: 'cf-full-width',
})
@@ -16,19 +16,18 @@ useHead({
title: () => route.meta.title as string,
})
// const roleAccess: PagePermission = PAGE_PERMISSIONS['/patient']
const roleAccess: RoleAccesses = PAGE_PERMISSIONS['/client/patient']
// const { checkRole, hasReadAccess } = useRBAC()
const { checkRole, hasReadAccess } = useRBAC()
// // Check if user has access to this page
// const hasAccess = checkRole(roleAccess)
// if (!hasAccess) {
// navigateTo('/403')
// }
// Check if user has access to this page
const hasAccess = checkRole(roleAccess)
if (!hasAccess) {
navigateTo('/403')
}
// Define permission-based computed properties
// const canRead = hasReadAccess(roleAccess)
const canRead = true
const canRead = hasReadAccess(roleAccess)
</script>
<template>
@@ -36,7 +35,7 @@ const canRead = true
<div v-if="canRead">
<ContentPatientForm
:mode="'edit'"
:patient-id="route.params.id"
:patient-id="route.params.id as string"
/>
</div>
<Error
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { PagePermission } from '~/models/role'
import type { RoleAccesses } from '~/models/role'
import Error from '~/components/pub/my-ui/error/error.vue'
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
@@ -16,7 +16,7 @@ useHead({
title: () => route.meta.title as string,
})
const roleAccess: PagePermission = PAGE_PERMISSIONS['/patient']
const roleAccess: RoleAccesses = PAGE_PERMISSIONS['/client/patient']
const { checkRole, hasReadAccess } = useRBAC()
+2 -2
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { PagePermission } from '~/models/role'
import type { RoleAccesses } from '~/models/role'
import Error from '~/components/pub/my-ui/error/error.vue'
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
@@ -16,7 +16,7 @@ useHead({
title: () => route.meta.title as string,
})
const roleAccess: PagePermission = PAGE_PERMISSIONS['/patient']
const roleAccess: RoleAccesses = PAGE_PERMISSIONS['/client/patient']
const { checkRole, hasReadAccess } = useRBAC()
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { PagePermission } from '~/models/role'
import type { RoleAccesses } from '~/models/role'
import Error from '~/components/pub/my-ui/error/error.vue'
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
@@ -16,8 +16,8 @@ useHead({
title: () => route.meta.title as string,
})
const roleAccess: PagePermission = PAGE_PERMISSIONS['/patient']
const roleAccess: RoleAccesses = PAGE_PERMISSIONS['/client/patient']
console.log(roleAccess)
const { checkRole, hasReadAccess } = useRBAC()
// Check if user has access to this page