Implement error handling in treatment report form submission and display toast notifications when errors occur. The form now emits error events and prevents default form submission behavior.
41 lines
894 B
Vue
41 lines
894 B
Vue
<script setup lang="ts">
|
|
// type
|
|
import { genDoctor, type Doctor } from '~/models/doctor'
|
|
import type { TreatmentReportFormData } from '~/schemas/treatment-report.schema'
|
|
|
|
// components
|
|
import { toast } from '~/components/pub/ui/toast'
|
|
import AppTreatmentReportEntry from '~/components/app/treatment-report/entry-form.vue'
|
|
|
|
const doctors = ref<Doctor[]>([])
|
|
|
|
// TODO: dummy data
|
|
;(() => {
|
|
doctors.value = [genDoctor()]
|
|
})()
|
|
</script>
|
|
|
|
<template>
|
|
<AppTreatmentReportEntry
|
|
:isLoading="false"
|
|
@submit="(val) => console.log(val)"
|
|
@error="
|
|
(err: Error) => {
|
|
toast({
|
|
title: 'Terjadi Kesalahan',
|
|
description: err.message,
|
|
variant: 'destructive',
|
|
})
|
|
}
|
|
"
|
|
:doctors="doctors"
|
|
:initialValues="
|
|
{
|
|
operatorTeam: {
|
|
// dpjpId: -1,
|
|
},
|
|
} as TreatmentReportFormData
|
|
"
|
|
/>
|
|
</template>
|