feat(patient): add patient handler and refactor form submission

- Introduce new patient handler using genCrudHandler for CRUD operations
- Refactor patient entry form to use handler for save operations
- Separate form data composition from submission logic
- Handle file uploads and navigation after successful submission
This commit is contained in:
Khafid Prayoga
2025-10-16 14:04:00 +07:00
parent 20b96ab7e4
commit 070239270e
3 changed files with 100 additions and 44 deletions
+13 -2
View File
@@ -129,23 +129,34 @@ export function genCrudHandler<T = any>(crud: {
recItem.value = null
}
async function handleActionSave(values: any, refresh: () => void, reset: () => void, toast: ToastFn) {
async function handleActionSave(
values: any,
refresh: () => void,
reset: () => void,
toast: ToastFn,
): Promise<any | null> {
isProcessing.value = true
let successResponse: any = null
await handleAsyncAction<[any], any>({
action: crud.create,
args: [values],
toast,
successMessage: 'Data berhasil disimpan',
errorMessage: 'Gagal menyimpan data',
onSuccess: () => {
onSuccess: (result) => {
isFormEntryDialogOpen.value = false
if (refresh) refresh()
successResponse = result
},
onFinally: (isSuccess: boolean) => {
if (isSuccess) setTimeout(reset, 500)
isProcessing.value = false
},
})
return successResponse
}
async function handleActionEdit(