From f3474eb0b530bb0363bfa342b4140cc2b0af1436 Mon Sep 17 00:00:00 2001 From: Khafid Prayoga Date: Mon, 24 Nov 2025 14:08:01 +0700 Subject: [PATCH] refactor(patient-contact): improve contact form components and validation - Remove hardcoded contact limit and use prop instead - Add ButtonAction component to form exports - Enhance contact schema validation with better error messages - Refactor contact type select component to use doc-entry components - Improve form layout and consistency between contact and relative forms --- .../app/person-contact/entry-form.vue | 122 ++++++++---------- .../fields/select-contact-type.vue | 39 +++--- .../app/person-relative/entry-form.vue | 12 +- app/components/content/patient/add.vue | 1 - app/components/pub/my-ui/form/index.ts | 1 + app/schemas/person-contact.schema.ts | 4 +- 6 files changed, 87 insertions(+), 92 deletions(-) diff --git a/app/components/app/person-contact/entry-form.vue b/app/components/app/person-contact/entry-form.vue index 266ba000..516f50ae 100644 --- a/app/components/app/person-contact/entry-form.vue +++ b/app/components/app/person-contact/entry-form.vue @@ -2,16 +2,18 @@ import { toTypedSchema } from '@vee-validate/zod' // components +import * as DE from '~/components/pub/my-ui/doc-entry' import { Form } from '~/components/pub/ui/form' import { FieldArray } from 'vee-validate' import { SelectContactType } from './fields' -import { InputBase } from '~/components/pub/my-ui/form' +import { ButtonAction, InputBase } from '~/components/pub/my-ui/form' const props = defineProps<{ title: string schema: any - contactLimit: number + contactLimit?: number initialValues?: any + isReadonly?: boolean }>() const { contactLimit = 5 } = props @@ -24,6 +26,8 @@ defineExpose({ setValues: (values: any, shouldValidate = true) => formRef.value?.setValues(values, shouldValidate), values: computed(() => formRef.value?.values), }) + +const { title = 'Kontak Pasien', isReadonly = false } = props diff --git a/app/components/app/person-contact/fields/select-contact-type.vue b/app/components/app/person-contact/fields/select-contact-type.vue index d6f8fe24..c63a0bee 100644 --- a/app/components/app/person-contact/fields/select-contact-type.vue +++ b/app/components/app/person-contact/fields/select-contact-type.vue @@ -1,14 +1,13 @@ diff --git a/app/components/app/person-relative/entry-form.vue b/app/components/app/person-relative/entry-form.vue index e8e51433..40b08c43 100644 --- a/app/components/app/person-relative/entry-form.vue +++ b/app/components/app/person-relative/entry-form.vue @@ -6,14 +6,14 @@ import { FieldArray } from 'vee-validate' import * as DE from '~/components/pub/my-ui/doc-entry' import { Form } from '~/components/pub/ui/form' import { SelectRelations } from './fields' -import InputBase from '~/components/pub/my-ui/form/input-base.vue' -import ButtonAction from '~/components/pub/my-ui/form/button-action.vue' +import { ButtonAction, InputBase } from '~/components/pub/my-ui/form' const props = defineProps<{ title: string schema: any isReadonly?: boolean initialValues?: any + contactLimit?: number }>() const formSchema = toTypedSchema(props.schema) @@ -26,7 +26,7 @@ defineExpose({ values: computed(() => formRef.value?.values), }) -const { title = 'Kontak Pasien', isReadonly = false } = props +const { title = 'Kontak Pasien', isReadonly = false, contactLimit = 5 } = props