stashing code
This commit is contained in:
89
packages/logic/domains/passengerinfo/data/entities.ts
Normal file
89
packages/logic/domains/passengerinfo/data/entities.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
import { z } from "zod";
|
||||
import {
|
||||
flightPriceDetailsModel,
|
||||
allBagDetailsModel,
|
||||
} from "../../ticket/data/entities";
|
||||
import { paymentDetailsModel } from "../../paymentinfo/data/entities";
|
||||
|
||||
export enum Gender {
|
||||
Male = "male",
|
||||
Female = "female",
|
||||
Other = "other",
|
||||
}
|
||||
|
||||
export enum PassengerType {
|
||||
Adult = "adult",
|
||||
Child = "child",
|
||||
}
|
||||
|
||||
export const passengerPIIModel = z.object({
|
||||
firstName: z.string().min(1).max(255),
|
||||
middleName: z.string().min(0).max(255),
|
||||
lastName: z.string().min(1).max(255),
|
||||
email: z.string().email(),
|
||||
phoneCountryCode: z.string().min(2).max(6).regex(/^\+/),
|
||||
phoneNumber: z.string().min(2).max(20),
|
||||
nationality: z.string().min(1).max(128),
|
||||
gender: z.enum([Gender.Male, Gender.Female, Gender.Other]),
|
||||
dob: z.string().date(),
|
||||
passportNo: z.string().min(1).max(64),
|
||||
// add a custom validator to ensure this is not expired (present or older)
|
||||
passportExpiry: z
|
||||
.string()
|
||||
.date()
|
||||
.refine(
|
||||
(v) => new Date(v).getTime() > new Date().getTime(),
|
||||
"Passport expiry must be in the future",
|
||||
),
|
||||
|
||||
country: z.string().min(1).max(128),
|
||||
state: z.string().min(1).max(128),
|
||||
city: z.string().min(1).max(128),
|
||||
zipCode: z.string().min(4).max(21),
|
||||
address: z.string().min(1).max(128),
|
||||
address2: z.string().min(0).max(128),
|
||||
});
|
||||
export type PassengerPII = z.infer<typeof passengerPIIModel>;
|
||||
|
||||
export const seatSelectionInfoModel = z.object({
|
||||
id: z.string(),
|
||||
row: z.string(),
|
||||
number: z.number(),
|
||||
seatLetter: z.string(),
|
||||
available: z.boolean(),
|
||||
reserved: z.boolean(),
|
||||
price: flightPriceDetailsModel,
|
||||
});
|
||||
export type SeatSelectionInfo = z.infer<typeof seatSelectionInfoModel>;
|
||||
|
||||
export const flightSeatMapModel = z.object({
|
||||
flightId: z.string(),
|
||||
seats: z.array(z.array(seatSelectionInfoModel)),
|
||||
});
|
||||
export type FlightSeatMap = z.infer<typeof flightSeatMapModel>;
|
||||
|
||||
export const bagSelectionInfoModel = z.object({
|
||||
id: z.number(),
|
||||
personalBags: z.number().default(1),
|
||||
handBags: z.number().default(0),
|
||||
checkedBags: z.number().default(0),
|
||||
pricing: allBagDetailsModel,
|
||||
});
|
||||
export type BagSelectionInfo = z.infer<typeof bagSelectionInfoModel>;
|
||||
|
||||
export const passengerInfoModel = z.object({
|
||||
id: z.number(),
|
||||
passengerType: z.enum([PassengerType.Adult, PassengerType.Child]),
|
||||
passengerPii: passengerPIIModel,
|
||||
paymentDetails: paymentDetailsModel.optional(),
|
||||
passengerPiiId: z.number().optional(),
|
||||
paymentDetailsId: z.number().optional(),
|
||||
seatSelection: seatSelectionInfoModel,
|
||||
bagSelection: bagSelectionInfoModel,
|
||||
|
||||
agentsInfo: z.boolean().default(false).optional(),
|
||||
agentId: z.coerce.string().optional(),
|
||||
flightTicketInfoId: z.number().optional(),
|
||||
orderId: z.number().optional(),
|
||||
});
|
||||
export type PassengerInfo = z.infer<typeof passengerInfoModel>;
|
||||
Reference in New Issue
Block a user