feat(encounter): enhance entry form with submit method and save functionality

This commit is contained in:
riefive
2025-11-09 17:43:55 +07:00
parent 5b15f86acb
commit 79e1d54710
2 changed files with 201 additions and 30 deletions
+14 -28
View File
@@ -131,11 +131,25 @@ const onSubmit = handleSubmit((values) => {
console.log('✅ Validated form values:', JSON.stringify(values, null, 2))
emit('event', 'save', values)
})
// Expose submit method for parent component
const formRef = ref<HTMLFormElement | null>(null)
function submitForm() {
if (formRef.value) {
formRef.value.requestSubmit()
}
}
defineExpose({
submitForm,
})
</script>
<template>
<div class="mx-auto w-full">
<form
ref="formRef"
@submit.prevent="onSubmit"
class="grid gap-6 p-4"
>
@@ -411,34 +425,6 @@ const onSubmit = handleSubmit((values) => {
/>
</Block>
</template>
<!-- Actions -->
<div class="mt-6 flex justify-end gap-2">
<Button
variant="outline"
type="button"
class="h-[40px] min-w-[120px] rounded-md border-orange-400 text-orange-400 hover:bg-green-50 hover:text-orange-400"
@click="emit('event', 'cancel')"
>
<Icon
name="i-lucide-x"
class="h-5 w-5"
/>
Batal
</Button>
<Button
type="button"
class="h-[40px] min-w-[120px] text-white"
:disabled="isLoading"
@click="onSubmit"
>
<Icon
name="i-lucide-save"
class="h-5 w-5"
/>
Simpan
</Button>
</div>
</form>
</div>
</template>