fix: Empty "Add guests" email input is blocking form submission (#14442)
This commit is contained in:
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user