import { dateSchema, timeSchema } from "@/common/schemas"; import z from "zod"; export const packageRequestSchema = z.object({ name: z .string("Must be string.") .nonempty("Must not empty.") .max(100, "Max 100 characters."), type: z.enum(["reguler", "plus"], "Must be either 'reguler' or 'plus'."), class: z.enum( ["silver", "gold", "platinum"], "Must be either 'silver', 'gold', or 'platinum'.", ), thumbnail: z.base64("Must be base64 string.").nonempty("Must not empty."), use_fast_train: z.boolean("Must be boolean."), }); export const packageDetailRequestSchema = z.object({ departure_date: dateSchema, tour_flight_ids: z .array( z .ulid("Must be ulid string.") .nonempty("Must not empty.") .max(30, "Max 30 characters."), "Must be array.", ) .nonempty("Must not empty.") .nullable(), outbound_flight_ids: z .array( z .ulid("Must be ulid string.") .nonempty("Must not empty.") .max(30, "Max 30 characters."), "Must be array.", ) .nonempty("Must not empty."), inbound_flight_ids: z .array( z .ulid("Must be ulid string.") .nonempty("Must not empty.") .max(30, "Max 30 characters."), "Must be array.", ) .nonempty("Must not empty."), tour_hotels: z .array( z.object( { hotel_id: z .ulid("Must be ulid string.") .nonempty("Must not empty.") .max(30, "Max 30 characters."), check_in: timeSchema, check_out: timeSchema, }, "Must be object.", ), "Must be array.", ) .nonempty("Must not empty.") .nullable(), makkah_hotel: z.object( { hotel_id: z .ulid("Must be ulid string.") .nonempty("Must not empty.") .max(30, "Max 30 characters."), check_in: timeSchema, check_out: timeSchema, }, "Must be object.", ), madinah_hotel: z.object( { hotel_id: z .ulid("Must be ulid string.") .nonempty("Must not empty.") .max(30, "Max 30 characters."), check_in: timeSchema, check_out: timeSchema, }, "Must be object.", ), transportation_id: z .ulid("Must be ulid string.") .nonempty("Must not empty.") .max(30, "Max 30 characters."), quad_price: z .number("Must be number.") .int("Must be integer.") .positive("Must be positive."), triple_price: z .number("Must be number.") .int("Must be integer.") .positive("Must be positive."), double_price: z .number("Must be number.") .int("Must be integer.") .positive("Must be positive."), infant_price: z .number("Must be number.") .int("Must be integer.") .positive("Must be positive.") .nullable(), itineraries: z.array( z.object( { location: z .string("Must be string.") .nonempty("Must not empty.") .max(100, "Max 100 characters."), images: z.array( z.base64("Must be base64 string.").nonempty("Must not empty."), "Must be array.", ), days: z.array( z.object( { title: z .string("Must be string.") .nonempty("Must not empty.") .max(100, "Max 100 characters."), description: z .string("Must be string.") .nonempty("Must not empty.") .max(1000, "Max 1000 characters."), widgets: z.array( z.discriminatedUnion("type", [ z.object( { type: z.literal("transport"), transportation: z .string("Must be string.") .nonempty("Must not empty.") .max(100, "Max 100 characters."), from: z .string("Must be string.") .nonempty("Must not empty.") .max(100, "Max 100 characters."), to: z .string("Must be string.") .nonempty("Must not empty.") .max(100, "Max 100 characters."), }, "Must be object.", ), z.object( { type: z.literal("hotel"), hotel_id: z .ulid("Must be ulid string.") .nonempty("Must not empty.") .max(30, "Max 30 characters."), }, "Must be object.", ), z.object( { type: z.literal("information"), description: z .string("Must be string.") .nonempty("Must not empty.") .max(1000, "Max 1000 characters."), }, "Must be object.", ), ]), "Must be array.", ), }, "Must be object.", ), "Must be array.", ), }, "Must be object.", ), "Must be array.", ), }); export const packageParamsSchema = z.object({ id: z .ulid("Must be ulid string.") .nonempty("Must not empty.") .max(30, "Max 30 characters."), }); export const packageDetailParamsSchema = z.object({ package_id: z .ulid("Must be ulid string.") .nonempty("Must not empty.") .max(30, "Max 30 characters."), id: z .ulid("Must be ulid string.") .nonempty("Must not empty.") .max(30, "Max 30 characters."), });