feat(BOOK-750): refactor booking endpoints * WIP * wip * wip * parse dates in UTC * wip * no more errors * Merge branch 'master' of bitbucket.org:scandic-swap/web into chore/refactor-trpc-booking-routes * . * cleanup * import named z from zod * fix(BOOK-750): updateBooking api endpoint expects dateOnly, we passed ISO date Approved-by: Anton Gunnarsson
75 lines
1.9 KiB
TypeScript
75 lines
1.9 KiB
TypeScript
import { z } from "zod"
|
|
|
|
import { Lang } from "@scandic-hotels/common/constants/language"
|
|
|
|
import { langToApiLang } from "../../constants/apiLang"
|
|
|
|
export const addPackageInput = z.object({
|
|
ancillaryComment: z.string(),
|
|
ancillaryDeliveryTime: z.string().nullish(),
|
|
packages: z.array(
|
|
z.object({
|
|
code: z.string(),
|
|
quantity: z.number(),
|
|
comment: z.string().optional(),
|
|
})
|
|
),
|
|
language: z.nativeEnum(Lang).transform((val) => langToApiLang[val]),
|
|
})
|
|
|
|
export const removePackageInput = z.object({
|
|
codes: z.array(z.string()),
|
|
language: z.nativeEnum(Lang).transform((val) => langToApiLang[val]),
|
|
})
|
|
|
|
export const resendConfirmationInput = z.object({
|
|
language: z.nativeEnum(Lang).transform((val) => langToApiLang[val]),
|
|
})
|
|
|
|
export const cancelBookingsInput = z.object({
|
|
language: z.nativeEnum(Lang),
|
|
})
|
|
|
|
export const createRefIdInput = z.object({
|
|
confirmationNumber: z
|
|
.string()
|
|
.trim()
|
|
.regex(/^\s*[0-9]+(-[0-9])?\s*$/)
|
|
.min(1),
|
|
lastName: z.string().trim().max(250).min(1),
|
|
})
|
|
|
|
export const updateBookingInput = z.object({
|
|
checkInDate: z.string().optional(),
|
|
checkOutDate: z.string().optional(),
|
|
guest: z
|
|
.object({
|
|
email: z.string().optional(),
|
|
phoneNumber: z.string().optional(),
|
|
countryCode: z.string().optional(),
|
|
})
|
|
.optional(),
|
|
language: z.nativeEnum(Lang),
|
|
})
|
|
|
|
// Query
|
|
|
|
export const getBookingInput = z.object({
|
|
lang: z.nativeEnum(Lang).optional(),
|
|
})
|
|
|
|
export const getLinkedReservationsInput = z.object({
|
|
lang: z.nativeEnum(Lang).optional(),
|
|
})
|
|
|
|
export const findBookingInput = z.object({
|
|
confirmationNumber: z.string(),
|
|
firstName: z.string(),
|
|
lastName: z.string(),
|
|
email: z.string(),
|
|
lang: z.nativeEnum(Lang).optional(),
|
|
})
|
|
|
|
export type LinkedReservationsInput = z.input<typeof getLinkedReservationsInput>
|
|
export type { CreateBookingInput } from "./mutation/createBookingRoute/schema"
|