feat(treatment-report): add error handling and toast notification
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.
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
<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'
|
||||
import type { TreatmentReportFormData } from '~/schemas/treatment-report.schema'
|
||||
|
||||
const doctors = ref<Doctor[]>([])
|
||||
|
||||
@@ -17,6 +18,16 @@ const doctors = ref<Doctor[]>([])
|
||||
<template>
|
||||
<AppTreatmentReportEntry
|
||||
:isLoading="false"
|
||||
@submit="(val) => console.log(val)"
|
||||
@error="
|
||||
(err: Error) => {
|
||||
toast({
|
||||
title: 'Terjadi Kesalahan',
|
||||
description: err.message,
|
||||
variant: 'destructive',
|
||||
})
|
||||
}
|
||||
"
|
||||
:doctors="doctors"
|
||||
:initialValues="
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user