Fix: add role authorization in Resume

This commit is contained in:
hasyim_kai
2025-11-18 11:19:48 +07:00
parent c28fc8f7aa
commit dab6adc4a9
3 changed files with 62 additions and 17 deletions

No files matched your search

+35 -17
View File
@@ -19,9 +19,17 @@ import Confirmation from '~/components/pub/my-ui/confirmation/confirmation.vue'
import type { ExposedForm } from '~/types/form'
import { VerificationSchema } from '~/schemas/verification.schema'
import DocPreviewDialog from '~/components/pub/my-ui/modal/doc-preview-dialog.vue'
import type { PagePermission } from '~/models/role'
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
import { unauthorizedToast } from '~/lib/utils'
// #endregion
// #region Permission
const roleAccess: PagePermission = PAGE_PERMISSIONS['/rehab/encounter']
const { getPagePermissions } = useRBAC()
const pagePermission = getPagePermissions(roleAccess)
// #region State
const { data, isLoading, paginationMeta, searchInput, handlePageChange, handleSearch, fetchData } = usePaginatedList({
fetchFn: (params) => getPatients({ ...params, includes: ['person', 'person-Addresses'] }),
@@ -55,11 +63,13 @@ provide('isCaptchaValid', isCaptchaValid)
const headerPrep: HeaderPrep = {
title: "Resume",
icon: 'i-lucide-newspaper',
addNav: {
label: "Resume",
onClick: () => navigateTo('/resume/add'),
},
}
}
if (pagePermission.canCreate) {
headerPrep.addNav = {
label: "Resume",
onClick: () => navigateTo('/resume/add'),
}
}
// #endregion
// #region Lifecycle Hooks
@@ -146,17 +156,25 @@ provide('table_data_loader', isLoading)
// #region Watchers
watch([recId, recAction], () => {
switch (recAction.value) {
case ActionEvents.showVerify:
isVerifyDialogOpen.value = true
break
case ActionEvents.showValidate:
isRecordConfirmationOpen.value = true
break
case ActionEvents.showPrint:
isDocPreviewDialogOpen.value = true
break
}
switch (recAction.value) {
case ActionEvents.showVerify:
if(pagePermission.canUpdate) {
isVerifyDialogOpen.value = true
} else {
unauthorizedToast()
}
break
case ActionEvents.showValidate:
if(pagePermission.canUpdate) {
isRecordConfirmationOpen.value = true
} else {
unauthorizedToast()
}
break
case ActionEvents.showPrint:
isDocPreviewDialogOpen.value = true
break
}
})
// #endregion
</script>