diff --git a/apps/scandic-web/components/HotelReservation/FindMyBooking/AdditionalInfoForm.tsx b/apps/scandic-web/components/HotelReservation/FindMyBooking/AdditionalInfoForm.tsx index c35295de3..8b27e5c73 100644 --- a/apps/scandic-web/components/HotelReservation/FindMyBooking/AdditionalInfoForm.tsx +++ b/apps/scandic-web/components/HotelReservation/FindMyBooking/AdditionalInfoForm.tsx @@ -31,6 +31,7 @@ export default function AdditionalInfoForm({ const intl = useIntl() const form = useForm({ resolver: zodResolver(additionalInfoFormSchema), + defaultValues: { firstName: "", email: "" }, mode: "all", criteriaMode: "all", reValidateMode: "onChange", diff --git a/apps/scandic-web/components/HotelReservation/FindMyBooking/schema.ts b/apps/scandic-web/components/HotelReservation/FindMyBooking/schema.ts index e9bc192eb..6f980a86a 100644 --- a/apps/scandic-web/components/HotelReservation/FindMyBooking/schema.ts +++ b/apps/scandic-web/components/HotelReservation/FindMyBooking/schema.ts @@ -13,6 +13,7 @@ const findMyBookingErrors = { BOOKING_NUMBER_REQUIRED: "BOOKING_NUMBER_REQUIRED", FIRST_NAME_REQUIRED: "FIRST_NAME_REQUIRED", LAST_NAME_REQUIRED: "LAST_NAME_REQUIRED", + EMAIL_INVALID: "EMAIL_INVALID", EMAIL_REQUIRED: "EMAIL_REQUIRED", } as const @@ -22,7 +23,11 @@ const additionalInfoFormSchema = z.object({ .trim() .max(250) .min(1, findMyBookingErrors.FIRST_NAME_REQUIRED), - email: z.string().max(250).email(findMyBookingErrors.EMAIL_REQUIRED), + email: z + .string() + .max(250) + .min(1, findMyBookingErrors.EMAIL_REQUIRED) + .email(findMyBookingErrors.EMAIL_INVALID), }) const findMyBookingFormSchema = additionalInfoFormSchema.extend({ diff --git a/apps/scandic-web/components/TempDesignSystem/Form/Input/index.tsx b/apps/scandic-web/components/TempDesignSystem/Form/Input/index.tsx index edf8f0c4b..0680b0358 100644 --- a/apps/scandic-web/components/TempDesignSystem/Form/Input/index.tsx +++ b/apps/scandic-web/components/TempDesignSystem/Form/Input/index.tsx @@ -36,7 +36,7 @@ const Input = forwardRef(function Input( ref ) { const intl = useIntl() - const { control, formState } = useFormContext() + const { control } = useFormContext() const numberAttributes: HTMLAttributes = {} if (type === "number") { numberAttributes.onWheel = function (evt: WheelEvent) { @@ -50,7 +50,7 @@ const Input = forwardRef(function Input( control={control} name={name} rules={registerOptions} - render={({ field, fieldState }) => ( + render={({ field, fieldState, formState }) => (