feat: SW-1588 Implemented booking code select-rate

This commit is contained in:
Hrishikesh Vaipurkar
2025-02-14 20:50:42 +01:00
parent 832b6c27e0
commit 8966e56820
28 changed files with 242 additions and 60 deletions

View File

@@ -70,6 +70,7 @@ import type { HotelDataWithUrl } from "@/types/hotel"
import type {
HotelsAvailabilityInputSchema,
HotelsByHotelIdsAvailabilityInputSchema,
RoomsAvailabilityInputSchema,
} from "@/types/trpc/routers/hotel/availability"
import type { HotelInput } from "@/types/trpc/routers/hotel/hotel"
import type { CityLocation } from "@/types/trpc/routers/hotel/locations"
@@ -801,6 +802,8 @@ export const hotelQueryRouter = router({
})
const bookingCodeAvailabilityResponse =
await getHotelsAvailabilityByCity(input, apiLang, ctx.serviceToken)
// If API or network failed with no response
if (!bookingCodeAvailabilityResponse) {
metrics.hotelsAvailabilityBookingCode.fail.add(1, {
...input,

View File

@@ -6,6 +6,8 @@ export const priceSchema = z.object({
currency: z.nativeEnum(CurrencyEnum),
pricePerNight: z.coerce.number(),
pricePerStay: z.coerce.number(),
regularPricePerNight: z.coerce.number().optional(),
regularPricePerStay: z.coerce.number().optional(),
})
export const productTypePriceSchema = z.object({

View File

@@ -5,6 +5,7 @@ import { productSchema } from "./product"
import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHotel/selectHotel"
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
import { RateTypeEnum } from "@/types/enums/rateType"
export const roomConfigurationSchema = z
.object({
@@ -43,6 +44,11 @@ export const roomConfigurationSchema = z
return product
}
// Return rate even if single when special rates
if (product.productType.public.rateType !== RateTypeEnum.Regular) {
return product
}
/**
* Reset both rateCodes if one is missing to show `No prices available` for the same reason as
* mentioned above.
@@ -67,12 +73,14 @@ export const roomConfigurationSchema = z
/**
* When all products miss at least one rateCode (member or public), we change the status to NotAvailable
* since we cannot as of now (31 january) guarantee the flow with missing rateCodes.
* Exception Special rate (Booking code rates)
*
* TODO: (Maybe) notify somewhere that this happened
*/
const allProductsMissAtLeastOneRateCode = data.products.every(
({ productType }) =>
!productType.public.rateCode || !productType.member?.rateCode
(!productType.public.rateCode || !productType.member?.rateCode) &&
productType.public.rateType === RateTypeEnum.Regular
)
if (allProductsMissAtLeastOneRateCode) {
data.status = AvailabilityEnum.NotAvailable

View File

@@ -3,7 +3,7 @@ import { z } from "zod"
export const rateDefinitionSchema = z.object({
breakfastIncluded: z.boolean(),
cancellationRule: z.string(),
cancellationText: z.string(),
cancellationText: z.string().optional(),
generalTerms: z.array(z.string()),
mustBeGuaranteed: z.boolean(),
rateCode: z.string(),