From 66ecb000f1f0b063e7f8eddebf709a5b8a36034a Mon Sep 17 00:00:00 2001 From: riefive Date: Sat, 15 Nov 2025 07:21:24 +0700 Subject: [PATCH] fix(encounter): add guard for encounter home --- .../app/encounter/dropdown-action.vue | 32 +++++++++++++++---- app/components/content/encounter/home.vue | 5 ++- app/components/pub/my-ui/data/types.ts | 1 + 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/app/components/app/encounter/dropdown-action.vue b/app/components/app/encounter/dropdown-action.vue index 3078d4a3..67c29710 100644 --- a/app/components/app/encounter/dropdown-action.vue +++ b/app/components/app/encounter/dropdown-action.vue @@ -10,11 +10,19 @@ const recId = inject>('rec_id')! const recAction = inject>('rec_action')! const recItem = inject>('rec_item')! const activeKey = ref(null) -const activePosition = inject>('position') +const activePosition = inject>('position')! const linkItemsFiltered = ref([]) +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) +})