Files
simrsx-fe/app/schemas/person-relative.schema.ts
Khafid Prayoga 97d2b76ee3 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
2025-12-10 20:30:34 +07:00

29 lines
1.0 KiB
TypeScript

import { z } from 'zod'
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' }).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')
.optional(),
occupation_name: z.string().optional(),
occupation_code: z.string().optional(),
education_code: z.string().optional(),
})
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 ResponsiblePersonRelativeSchema>
export { ResponsiblePersonRelativeSchema }
export type { PersonRelativeFormData }