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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user