fix(encounter): add guard for encounter home
This commit is contained in:
@@ -10,11 +10,19 @@ const recId = inject<Ref<number>>('rec_id')!
|
||||
const recAction = inject<Ref<string>>('rec_action')!
|
||||
const recItem = inject<Ref<any>>('rec_item')!
|
||||
const activeKey = ref<string | null>(null)
|
||||
const activePosition = inject<Ref<string>>('position')
|
||||
const activePosition = inject<Ref<string>>('position')!
|
||||
const linkItemsFiltered = ref<LinkItem[]>([])
|
||||
const linkItemsBase: LinkItem[] = [
|
||||
{
|
||||
label: 'Nothing',
|
||||
value: 'nothing',
|
||||
icon: 'i-lucide-file',
|
||||
},
|
||||
]
|
||||
const linkItems: LinkItem[] = [
|
||||
{
|
||||
label: 'Detail',
|
||||
value: 'detail',
|
||||
onClick: () => {
|
||||
detail()
|
||||
},
|
||||
@@ -22,6 +30,7 @@ const linkItems: LinkItem[] = [
|
||||
},
|
||||
{
|
||||
label: 'Edit',
|
||||
value: 'edit',
|
||||
onClick: () => {
|
||||
edit()
|
||||
},
|
||||
@@ -29,6 +38,7 @@ const linkItems: LinkItem[] = [
|
||||
},
|
||||
{
|
||||
label: 'Print',
|
||||
value: 'print',
|
||||
onClick: () => {
|
||||
print()
|
||||
},
|
||||
@@ -36,6 +46,7 @@ const linkItems: LinkItem[] = [
|
||||
},
|
||||
{
|
||||
label: 'Batalkan',
|
||||
value: 'cancel',
|
||||
onClick: () => {
|
||||
cancel()
|
||||
},
|
||||
@@ -43,6 +54,7 @@ const linkItems: LinkItem[] = [
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
value: 'remove',
|
||||
onClick: () => {
|
||||
remove()
|
||||
},
|
||||
@@ -80,23 +92,29 @@ function remove() {
|
||||
recItem.value = props.rec
|
||||
}
|
||||
|
||||
linkItemsFiltered.value = [...linkItems]
|
||||
linkItemsFiltered.value = [...linkItemsBase]
|
||||
|
||||
if (activePosition) {
|
||||
switch (activePosition.value) {
|
||||
function getLinks(position: string) {
|
||||
switch (position) {
|
||||
case 'medical':
|
||||
linkItemsFiltered.value = [...linkItems]
|
||||
break
|
||||
case 'verificator':
|
||||
linkItemsFiltered.value = [
|
||||
...linkItems.filter((item) => ['Detail', 'Print'].includes(item.label)),
|
||||
...linkItems.filter((item) => ['detail', 'print'].includes(item.value || '')),
|
||||
]
|
||||
break
|
||||
default:
|
||||
linkItemsFiltered.value = [...linkItems]
|
||||
linkItemsFiltered.value = [...linkItemsBase]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
getLinks(activePosition.value)
|
||||
|
||||
watch(activePosition, () => {
|
||||
getLinks(activePosition.value)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -119,7 +137,7 @@ if (activePosition) {
|
||||
>
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
v-for="item in linkItems"
|
||||
v-for="item in linkItemsFiltered"
|
||||
:key="item.label"
|
||||
class="hover:bg-gray-100 dark:hover:bg-slate-700"
|
||||
@click="item.onClick"
|
||||
|
||||
@@ -44,9 +44,12 @@ const activeTab = computed({
|
||||
})
|
||||
|
||||
const id = typeof route.params.id == 'string' ? parseInt(route.params.id) : 0
|
||||
|
||||
const data = ref<any>(null)
|
||||
|
||||
if (activePosition.value === 'none') { // if user position is none, redirect to home page
|
||||
router.push('/')
|
||||
}
|
||||
|
||||
// Function to check if date is invalid (like "0001-01-01T00:00:00Z")
|
||||
function isValidDate(dateString: string | null | undefined): boolean {
|
||||
if (!dateString) return false
|
||||
|
||||
@@ -64,6 +64,7 @@ export interface KeyNames {
|
||||
|
||||
export interface LinkItem {
|
||||
label: string
|
||||
value?: string
|
||||
icon?: string
|
||||
href?: string // to cover the needs of stating full external origins full url
|
||||
action?: string // for local paths
|
||||
|
||||
Reference in New Issue
Block a user