refactor(person-relative): update schema and form components for family data

- Change value format in radio-parents-input from '1'/'0' to 'yes'/'no'
- Remove default labels from select-education and select-job components
- Update schema to make fields optional and add new fields
- Modify family-parents-form to use new schema and improve UI
- Update patient form and models to align with schema changes
This commit is contained in:
Khafid Prayoga
2025-12-10 20:30:34 +07:00
parent 3cac23ce8a
commit 97d2b76ee3
10 changed files with 110 additions and 152 deletions

No files matched your search

+14 -8
View File
@@ -1,22 +1,28 @@
import { z } from 'zod'
const ResponsibleContactPersonSchema = z.object({
const PersonRelativeSchema = z.object({
id: z.number().optional(),
relation: z.string({ required_error: 'Pilih jenis Penanggung Jawab' }).min(1, 'Pilih jenis Penanggung Jawab'),
name: z.string({ required_error: 'Mohon lengkapi Nama' }).min(3, 'Mohon lengkapi Nama'),
address: z.string({ required_error: 'Mohon lengkapi Alamat' }).min(3, 'Mohon lengkapi Alamat'),
name: z.string({ required_error: 'Mohon lengkapi Nama' }).optional(),
address: z.string({ required_error: 'Mohon lengkapi Alamat' }).optional(),
phone: z
.string({ required_error: 'Mohon lengkapi Nomor HP' })
.min(8, 'Nomor HP minimal 10 digit')
.max(15, 'Nomor HP maksimal 15 digit'),
.max(15, 'Nomor HP maksimal 15 digit')
.optional(),
occupation_name: z.string().optional(),
occupation_code: z.string().optional(),
education_code: z.string().optional(),
})
const ResponsiblePersonSchema = z.object({
contacts: z.array(ResponsibleContactPersonSchema).min(1, 'Minimal harus ada 1 penanggung jawab'),
const ResponsiblePersonRelativeSchema = z.object({
contacts: z.array(PersonRelativeSchema).optional(),
families: z.array(PersonRelativeSchema).optional(),
_shareFamilyData: z.enum(['yes', 'no']).optional(),
})
type PersonRelativeFormData = z.infer<typeof ResponsiblePersonSchema>
type PersonRelativeFormData = z.infer<typeof ResponsiblePersonRelativeSchema>
export { ResponsiblePersonSchema }
export { ResponsiblePersonRelativeSchema }
export type { PersonRelativeFormData }