diff --git a/app/components/app/material/entry-form.vue b/app/components/app/equipment/entry-form.vue similarity index 72% rename from app/components/app/material/entry-form.vue rename to app/components/app/equipment/entry-form.vue index 81951d91..f54a8389 100644 --- a/app/components/app/material/entry-form.vue +++ b/app/components/app/equipment/entry-form.vue @@ -2,23 +2,26 @@ // types import type z from 'zod' import type { MaterialFormData } from '~/schemas/material' +<<<<<<< HEAD:app/components/app/equipment/entry-form.vue +======= // helpers import { toTypedSchema } from '@vee-validate/zod' import { useForm } from 'vee-validate' // components import Label from '~/components/pub/custom-ui/form/label.vue' +>>>>>>> 266d5f740b15942ca7b8845c00573640fdc9a3b2:app/components/app/material/entry-form.vue interface Props { - isLoading: boolean schema: z.ZodSchema uoms: any[] items: any[] } +const isLoading = ref(false) const props = defineProps() const emit = defineEmits<{ - back: [] - submit: [data: any] + submit: [values: MaterialFormData, resetForm: () => void] + cancel: [resetForm: () => void] }>() const { handleSubmit, defineField, errors } = useForm({ @@ -38,19 +41,36 @@ const [uom, uomAttrs] = defineField('uom_code') const [item, itemAttrs] = defineField('item_id') const [stock, stockAttrs] = defineField('stock') -const onSubmit = handleSubmit(async (values) => { - try { - emit('submit', values) - } catch (error) { - console.error('Submission failed:', error) +const resetForm = () => { + code.value = '' + name.value = '' + uom.value = '' + item.value = '' + stock.value = 0 +} + +// Form submission handler +function onSubmitForm(values: any) { + const formData: MaterialFormData = { + name: values.name || '', + code: values.code || '', + uom_code: values.uom_code || '', + item_id: values.item_id || '', + stock: values.stock || 0, } -}) + emit('submit', formData, resetForm) +} + +// Form cancel handler +function onCancelForm() { + emit('cancel', resetForm) +}