fix: special requests

This commit is contained in:
Christel Westerberg
2024-12-10 14:40:26 +01:00
parent 854563d099
commit 241e354fc5
16 changed files with 393 additions and 18 deletions

View File

@@ -8,6 +8,24 @@ const stringMatcher =
const isValidString = (key: string) => stringMatcher.test(key)
export enum FloorPreference {
LOW = "Low level",
HIGH = "High level",
}
export enum ElevatorPreference {
AWAY_FROM_ELEVATOR = "Away from elevator",
NEAR_ELEVATOR = "Near elevator",
}
const specialRequestsSchema = z
.object({
floorPreference: z.nativeEnum(FloorPreference).optional(),
elevatorPreference: z.nativeEnum(ElevatorPreference).optional(),
comments: z.string().optional(),
})
.optional()
export const baseDetailsSchema = z.object({
countryCode: z.string().min(1, { message: "Country is required" }),
email: z.string().email({ message: "Email address is required" }),
@@ -24,6 +42,7 @@ export const baseDetailsSchema = z.object({
message: "Last name can't contain any special characters",
}),
phoneNumber: phoneValidator(),
specialRequests: specialRequestsSchema,
})
export const notJoinDetailsSchema = baseDetailsSchema.merge(
@@ -78,4 +97,5 @@ export const signedInDetailsSchema = z.object({
.transform((_) => false),
dateOfBirth: z.string().default(""),
zipCode: z.string().default(""),
specialRequests: specialRequestsSchema,
})