fix edit form state
fix: id list for contacts and address list fix warning fix duplicate contacts responsible: true fix edit family fix nik required
This commit is contained in:
@@ -6,11 +6,6 @@ const PatientSchema = z
|
||||
.object({
|
||||
// Data Diri Pasien
|
||||
identityNumber: z.string().optional(),
|
||||
// .string({
|
||||
// required_error: 'Mohon lengkapi NIK',
|
||||
// })
|
||||
// .min(16, 'NIK harus berupa angka 16 digit')
|
||||
// .regex(/^\d+$/, 'NIK harus berupa angka 16 digit'),
|
||||
residentIdentityFile: z
|
||||
.any()
|
||||
.optional()
|
||||
@@ -58,8 +53,8 @@ const PatientSchema = z
|
||||
nationality: z.string({
|
||||
required_error: 'Pilih Kebangsaan',
|
||||
}),
|
||||
isNewBorn: z.string({
|
||||
required_error: 'Mohon lengkapi status pasien',
|
||||
isNewBorn: z.union([z.boolean(), z.string()], {
|
||||
required_error: 'Mohon lengkapi Status Disabilitas',
|
||||
}),
|
||||
language: z.string({
|
||||
required_error: 'Mohon pilih Preferensi Bahasa',
|
||||
@@ -84,7 +79,7 @@ const PatientSchema = z
|
||||
|
||||
// Informasi Kontak
|
||||
passportNumber: z.string().optional(),
|
||||
communicationBarrier: z.string({
|
||||
communicationBarrier: z.union([z.boolean(), z.string()], {
|
||||
required_error: 'Mohon lengkapi Status Hambatan Berkomunikasi',
|
||||
}),
|
||||
|
||||
@@ -103,6 +98,19 @@ const PatientSchema = z
|
||||
path: ['disabilityType'],
|
||||
},
|
||||
)
|
||||
.refine(
|
||||
(data) => {
|
||||
if (data.nationality === 'WNI') {
|
||||
const nik = data.identityNumber?.trim()
|
||||
return !!nik && nik.length === 16 && /^\d+$/.test(nik)
|
||||
}
|
||||
return true
|
||||
},
|
||||
{
|
||||
message: 'NIK harus berupa angka 16 digit',
|
||||
path: ['identityNumber'],
|
||||
},
|
||||
)
|
||||
// .transform((data) => {
|
||||
// return {
|
||||
// ...data,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
const PersonAddressSchema = z.object({
|
||||
id: z.number().optional(),
|
||||
|
||||
locationType_code: z.string({
|
||||
required_error: 'Mohon pilih jenis alamat',
|
||||
}),
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
const PersonContactBaseSchema = z.object({
|
||||
id: z.number().optional(),
|
||||
|
||||
contactType: z.string({ required_error: 'Mohon pilih tipe kontak' }).min(1, 'Mohon pilih tipe kontak'),
|
||||
contactNumber: z.string({ required_error: 'Nomor kontak harus diisi' }).min(8, 'Nomor minimal 8 digit'),
|
||||
})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
const PersonFamilySchema = z.object({
|
||||
id: z.number().optional(),
|
||||
relation: z.enum(['mother', 'father', 'guardian', 'emergency_contact']),
|
||||
name: z
|
||||
.string({
|
||||
@@ -29,6 +30,7 @@ const PersonFamiliesSchema = z.discriminatedUnion('shareFamilyData', [
|
||||
interface PersonFamiliesFormData {
|
||||
shareFamilyData: '0' | '1'
|
||||
families: {
|
||||
id?: number
|
||||
relation: 'mother' | 'father' | 'guardian' | 'emergency_contact'
|
||||
name: string
|
||||
education: string
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
const ResponsibleContactPersonSchema = 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'),
|
||||
|
||||
Reference in New Issue
Block a user