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:
@@ -1,4 +1,4 @@
|
||||
import type { RoleAccess } from '~/models/role'
|
||||
import type { RoleAccesses } from '~/models/role'
|
||||
|
||||
export const PAGE_PERMISSIONS = {
|
||||
'/client/patient': {
|
||||
@@ -63,4 +63,4 @@ export const PAGE_PERMISSIONS = {
|
||||
'emp|pay': ['R'],
|
||||
'emp|mng': ['R'],
|
||||
},
|
||||
} as const satisfies Record<string, RoleAccess>
|
||||
} as const satisfies Record<string, RoleAccesses>
|
||||
|
||||
+1
-3
@@ -19,9 +19,7 @@ export interface TreeItem {
|
||||
|
||||
export function genBase(): Base {
|
||||
return {
|
||||
// -1 buat mock data
|
||||
// backend harusnya non-negative/ > 0 (untuk auto increment constraint) jadi harusnya aman ya
|
||||
id: -1,
|
||||
id: 0,
|
||||
createdAt: '',
|
||||
updatedAt: '',
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ export interface Person extends Base {
|
||||
export function genPerson(): Person {
|
||||
return {
|
||||
...genBase(),
|
||||
frontTitle: '[MOCK] dr. ',
|
||||
name: 'Agus Iwan Setiawan',
|
||||
endTitle: 'Sp.Bo',
|
||||
frontTitle: '',
|
||||
name: '',
|
||||
endTitle: '',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user