fix: Empty "Add guests" email input is blocking form submission (#14442)

This commit is contained in:
Amit Sharma
2024-04-08 13:24:15 +00:00
committed by GitHub
parent 6390d595f5
commit 260521fb28
2 changed files with 7 additions and 1 deletions
@@ -7,7 +7,7 @@ import type { FieldError } from "react-hook-form";
import { IS_CALCOM, WEBSITE_URL } from "@calcom/lib/constants";
import getPaymentAppData from "@calcom/lib/getPaymentAppData";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Alert, Button, EmptyScreen, Form, Icon } from "@calcom/ui";
import { Alert, Button, EmptyScreen, Form } from "@calcom/ui";
import { useBookerStore } from "../../store";
import type { useEventReturnType } from "../../utils/event";
@@ -170,6 +170,12 @@ function preprocess<T extends z.ZodType>({
}
if (!emailsParsed.success) {
// If additional guests are shown but all inputs are empty then don't show any errors
if (bookingField.name === "guests" && value.every((email: string) => email === "")) {
// reset guests to empty array, otherwise it adds "" for every input
responses[bookingField.name] = [];
continue;
}
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: m("email_validation_error"),