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:
Khafid Prayoga
2025-11-25 21:12:18 +07:00
parent 6a29fdfd50
commit f5704536d1
2 changed files with 25 additions and 3 deletions
@@ -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="
{