diff --git a/react-app/src/components/ActionForm/index.tsx b/react-app/src/components/ActionForm/index.tsx index 77dee40f78..b1dfe0198d 100644 --- a/react-app/src/components/ActionForm/index.tsx +++ b/react-app/src/components/ActionForm/index.tsx @@ -39,7 +39,7 @@ type EnforceSchemaProps = z.ZodObject< attachments?: z.ZodObject<{ [Key in keyof Shape]: z.ZodObject<{ label: z.ZodDefault; - files: z.ZodTypeAny; + files: z.ZodArray | z.ZodOptional>; }>; }>; }, diff --git a/react-app/src/features/forms/post-submission/upload-subsequent-documents/index.tsx b/react-app/src/features/forms/post-submission/upload-subsequent-documents/index.tsx index 184ea0fa99..cf7360d428 100644 --- a/react-app/src/features/forms/post-submission/upload-subsequent-documents/index.tsx +++ b/react-app/src/features/forms/post-submission/upload-subsequent-documents/index.tsx @@ -26,13 +26,18 @@ const pickAttachmentsAndAdditionalInfo = ( const shape = schema._def.shape(); const optionalAttachmentsShape = Object.fromEntries( - Object.entries(shape.attachments.shape).map(([key, value]) => [ - key, - z.object({ - files: value._def.shape().files.optional(), - label: value._def.shape().label, - }), - ]), + Object.entries(shape.attachments.shape).map(([key, value]) => { + const files = value._def.shape().files; + const filesArray = files instanceof z.ZodArray ? files : files.unwrap(); + + return [ + key, + z.object({ + files: z.array(filesArray.element).optional(), + label: value._def.shape().label, + }), + ]; + }), ); return z