From 16626a2feeb158319d2e8a5c4e6c01c8035640c7 Mon Sep 17 00:00:00 2001 From: Andrian Roshandy Date: Thu, 13 Nov 2025 11:49:28 +0700 Subject: [PATCH] feat/prescription: added submit --- app/components/app/prescription/list.vue | 1 - app/components/content/prescription/list.vue | 39 ++++++++++++++++--- .../confirmation/record-confirmation.vue | 5 ++- app/handlers/prescription.handler.ts | 2 +- app/services/prescription.service.ts | 14 +++++++ 5 files changed, 51 insertions(+), 10 deletions(-) diff --git a/app/components/app/prescription/list.vue b/app/components/app/prescription/list.vue index ae5126ca..fbff7b10 100644 --- a/app/components/app/prescription/list.vue +++ b/app/components/app/prescription/list.vue @@ -5,7 +5,6 @@ import Nav from '~/components/pub/my-ui/nav-footer/ca-ed-su.vue' import type { Prescription } from '~/models/prescription'; import PrescriptionItem from '~/components/app/prescription-item/list.vue'; -import { add } from 'date-fns'; interface Props { data: Prescription[] diff --git a/app/components/content/prescription/list.vue b/app/components/content/prescription/list.vue index 844cb04f..68e2069f 100644 --- a/app/components/content/prescription/list.vue +++ b/app/components/content/prescription/list.vue @@ -22,6 +22,8 @@ import { import { getList, getDetail } from '~/services/prescription.service' import List from '~/components/app/prescription/list.vue' import type { Prescription } from '~/models/prescription' +import { submit } from '~/services/prescription.service' +import type { ToastFn } from '~/handlers/_handler' const props = defineProps<{ encounter_id: number @@ -31,6 +33,7 @@ const route = useRoute() const { setQueryParams } = useQueryParam() const title = ref('') +const isSubmitConfirmationOpen = ref(false) const plainEid = route.params.id const encounter_id = (plainEid && typeof plainEid == 'string') ? parseInt(plainEid) : 0 @@ -125,13 +128,13 @@ watch([isFormEntryDialogOpen], async () => { } }) -function cancel(data: Prescription) { +function confirmCancel(data: Prescription) { recId.value = data.id recItem.value = data isRecordConfirmationOpen.value = true } -function edit(data: Prescription) { +function goToEdit(data: Prescription) { setQueryParams({ 'mode': 'entry', 'id': data.id.toString() @@ -139,9 +142,21 @@ function edit(data: Prescription) { recItem.value = data } -function submit(data: Prescription) { +function confirmSubmit(data: Prescription) { + recId.value = data.id + recItem.value = data + isSubmitConfirmationOpen.value = true } +async function handleActionSubmit(id: number, refresh: () => void, toast: ToastFn) { + const result = await submit(id) + if (result.success) { + toast({ title: 'Berhasil', description: 'Resep telah di ajukan', variant: 'default' }) + setTimeout(refresh, 300) + } else { + toast({ title: 'Gagal', description: 'Gagal menjalankan perintah', variant: 'destructive' }) + } +} diff --git a/app/components/pub/my-ui/confirmation/record-confirmation.vue b/app/components/pub/my-ui/confirmation/record-confirmation.vue index cff54b2b..b241b2c4 100644 --- a/app/components/pub/my-ui/confirmation/record-confirmation.vue +++ b/app/components/pub/my-ui/confirmation/record-confirmation.vue @@ -119,8 +119,9 @@ function handleCancel() {