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:
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
import type { RoleAccess } from '~/models/role'
|
import type { RoleAccesses } from '~/models/role'
|
||||||
|
|
||||||
export const PAGE_PERMISSIONS = {
|
export const PAGE_PERMISSIONS = {
|
||||||
'/client/patient': {
|
'/client/patient': {
|
||||||
@@ -63,4 +63,4 @@ export const PAGE_PERMISSIONS = {
|
|||||||
'emp|pay': ['R'],
|
'emp|pay': ['R'],
|
||||||
'emp|mng': ['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 {
|
export function genBase(): Base {
|
||||||
return {
|
return {
|
||||||
// -1 buat mock data
|
id: 0,
|
||||||
// backend harusnya non-negative/ > 0 (untuk auto increment constraint) jadi harusnya aman ya
|
|
||||||
id: -1,
|
|
||||||
createdAt: '',
|
createdAt: '',
|
||||||
updatedAt: '',
|
updatedAt: '',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ export interface Person extends Base {
|
|||||||
export function genPerson(): Person {
|
export function genPerson(): Person {
|
||||||
return {
|
return {
|
||||||
...genBase(),
|
...genBase(),
|
||||||
frontTitle: '[MOCK] dr. ',
|
frontTitle: '',
|
||||||
name: 'Agus Iwan Setiawan',
|
name: '',
|
||||||
endTitle: 'Sp.Bo',
|
endTitle: '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<script setup lang="ts">
|
<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 Error from '~/components/pub/my-ui/error/error.vue'
|
||||||
// import { PAGE_PERMISSIONS } from '~/lib/page-permission'
|
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
// middleware: ['rbac'],
|
middleware: ['rbac'],
|
||||||
roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'],
|
roles: ['doctor', 'nurse', 'admisi', 'pharmacy', 'billing', 'management'],
|
||||||
title: 'Daftar Divisi',
|
title: 'Edit Pasien',
|
||||||
contentFrame: 'cf-full-width',
|
contentFrame: 'cf-full-width',
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -16,19 +16,18 @@ useHead({
|
|||||||
title: () => route.meta.title as string,
|
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
|
// Check if user has access to this page
|
||||||
// const hasAccess = checkRole(roleAccess)
|
const hasAccess = checkRole(roleAccess)
|
||||||
// if (!hasAccess) {
|
if (!hasAccess) {
|
||||||
// navigateTo('/403')
|
navigateTo('/403')
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Define permission-based computed properties
|
// Define permission-based computed properties
|
||||||
// const canRead = hasReadAccess(roleAccess)
|
const canRead = hasReadAccess(roleAccess)
|
||||||
const canRead = true
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -36,7 +35,7 @@ const canRead = true
|
|||||||
<div v-if="canRead">
|
<div v-if="canRead">
|
||||||
<ContentPatientForm
|
<ContentPatientForm
|
||||||
:mode="'edit'"
|
:mode="'edit'"
|
||||||
:patient-id="route.params.id"
|
:patient-id="route.params.id as string"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Error
|
<Error
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<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 Error from '~/components/pub/my-ui/error/error.vue'
|
||||||
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
|
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ useHead({
|
|||||||
title: () => route.meta.title as string,
|
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()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<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 Error from '~/components/pub/my-ui/error/error.vue'
|
||||||
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
|
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ useHead({
|
|||||||
title: () => route.meta.title as string,
|
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()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<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 Error from '~/components/pub/my-ui/error/error.vue'
|
||||||
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
|
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
|
||||||
|
|
||||||
@@ -16,8 +16,8 @@ useHead({
|
|||||||
title: () => route.meta.title as string,
|
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()
|
const { checkRole, hasReadAccess } = useRBAC()
|
||||||
|
|
||||||
// Check if user has access to this page
|
// Check if user has access to this page
|
||||||
|
|||||||
Reference in New Issue
Block a user