mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 06:28:12 +00:00
Set email field optional in passenger information
This commit is contained in:
@@ -568,9 +568,8 @@ function createFormSchema(adultCount: number) {
|
|||||||
// Contact fields are only collected from — and validated against — adults.
|
// Contact fields are only collected from — and validated against — adults.
|
||||||
// Children's phone/email are inherited from the primary adult, not user-entered.
|
// Children's phone/email are inherited from the primary adult, not user-entered.
|
||||||
if (isAdult) {
|
if (isAdult) {
|
||||||
if (!p.email || p.email.trim().length === 0) {
|
// Email is optional — only validate its format when the user actually provides one.
|
||||||
ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Email is required', path: ['passengers', i, 'email'] });
|
if (p.email && p.email.trim().length > 0) {
|
||||||
} else {
|
|
||||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||||
if (!emailRegex.test(p.email)) {
|
if (!emailRegex.test(p.email)) {
|
||||||
ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Invalid email format', path: ['passengers', i, 'email'] });
|
ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Invalid email format', path: ['passengers', i, 'email'] });
|
||||||
@@ -1191,7 +1190,7 @@ export default function PassengersPage() {
|
|||||||
|
|
||||||
{/* Email */}
|
{/* Email */}
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium mb-1 text-gray-700 dark:text-gray-300">Email *</label>
|
<label className="block text-sm font-medium mb-1 text-gray-700 dark:text-gray-300">Email (optional)</label>
|
||||||
<input
|
<input
|
||||||
type="email"
|
type="email"
|
||||||
{...register(`passengers.${index}.email`)}
|
{...register(`passengers.${index}.email`)}
|
||||||
@@ -1280,7 +1279,7 @@ export default function PassengersPage() {
|
|||||||
|
|
||||||
{/* Email */}
|
{/* Email */}
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium mb-1 text-gray-700 dark:text-gray-300">Email *</label>
|
<label className="block text-sm font-medium mb-1 text-gray-700 dark:text-gray-300">Email (optional)</label>
|
||||||
<input
|
<input
|
||||||
type="email"
|
type="email"
|
||||||
{...register(`passengers.${index}.email`)}
|
{...register(`passengers.${index}.email`)}
|
||||||
|
|||||||
Reference in New Issue
Block a user