Merge remote-tracking branch 'origin/feat/uploads-85' into feat/medicine-form-167

This commit is contained in:
hasyim_kai
2025-11-17 09:18:47 +07:00
23 changed files with 1071 additions and 21 deletions
+24
View File
@@ -0,0 +1,24 @@
import { z } from 'zod'
const ACCEPTED_UPLOAD_TYPES = ['image/jpeg', 'image/png', 'application/pdf']
const MAX_SIZE_BYTES = 1 * 1024 * 1024 // 1MB
const DocumentUploadSchema = z.object({
entityType_code: z.string().default('encounter'),
ref_id: z.number(),
upload_employee_id: z.number(),
name: z.string({ required_error: 'Mohon isi', }),
type_code: z.string({ required_error: 'Mohon isi', }),
content: z.custom<File>()
.refine((f) => f, { message: 'File tidak boleh kosong' })
.refine((f) => !f || f instanceof File, { message: 'Harus berupa file yang valid' })
.refine((f) => !f || ACCEPTED_UPLOAD_TYPES.includes(f.type), {
message: 'Format file harus JPG, PNG, atau PDF',
})
.refine((f) => !f || f.size <= MAX_SIZE_BYTES, { message: 'Maksimal 1MB' }),
})
type DocumentUploadFormData = z.infer<typeof DocumentUploadSchema>
export { DocumentUploadSchema }
export type { DocumentUploadFormData }