From fe09d0e25f6fbfc4e1c9302054d3387fe8b1f0ea Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Tue, 2 Jan 2024 21:33:15 +0100 Subject: [PATCH] fix: don't show validation error on upload modal if password or max views are empty --- .../upload/modals/showCreateUploadModal.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/upload/modals/showCreateUploadModal.tsx b/frontend/src/components/upload/modals/showCreateUploadModal.tsx index 67f67663..0957425d 100644 --- a/frontend/src/components/upload/modals/showCreateUploadModal.tsx +++ b/frontend/src/components/upload/modals/showCreateUploadModal.tsx @@ -92,8 +92,15 @@ const CreateUploadModalBody = ({ .matches(new RegExp("^[a-zA-Z0-9_-]*$"), { message: t("upload.modal.link.error.invalid"), }), - password: yup.string().min(3).max(30), - maxViews: yup.number().min(1), + password: yup + .string() + .transform((value) => value || undefined) + .min(3) + .max(30), + maxViews: yup + .number() + .transform((value) => value || undefined) + .min(1), }); const form = useForm({ @@ -151,8 +158,8 @@ const CreateUploadModalBody = ({ recipients: values.recipients, description: values.description, security: { - password: values.password, - maxViews: values.maxViews, + password: values.password || undefined, + maxViews: values.maxViews || undefined, }, }, files,