From d49e3016343c775f36c5d0bc108d6ab15647d2a7 Mon Sep 17 00:00:00 2001 From: Bianca Widstam Date: Mon, 18 Nov 2024 15:08:12 +0000 Subject: [PATCH] fix/SW-902-update-response-city-availability (pull request #917) Fix/SW-902 update response city availability * fix(SW-902): update response for API changes * fix(SW-902): add total row for pricePerStay * fix(SW-902): fix optional requestedPrice * fix(SW-902): fix bookingCode output * feat(SW-903): fix sorting Approved-by: Pontus Dreij Approved-by: Niclas Edenvin --- .../(standard)/[step]/@summary/page.tsx | 20 +++--- .../(standard)/select-hotel/utils.ts | 22 +----- .../EnterDetails/Summary/index.tsx | 52 ++++++++------ .../HotelPriceList/HotelPriceCard/index.tsx | 63 +++++++++++------ .../HotelPriceList/hotelPriceList.module.css | 11 +++ .../HotelCard/HotelPriceList/index.tsx | 50 +++++++++---- .../HotelCard/hotelCard.module.css | 7 -- .../HotelReservation/HotelCard/index.tsx | 20 +----- .../HotelCardDialogListing/utils.ts | 6 +- .../HotelCardListing/index.tsx | 12 +++- .../SelectRate/Rooms/utils.ts | 2 +- i18n/dictionaries/de.json | 1 - i18n/dictionaries/en.json | 1 - i18n/dictionaries/fi.json | 1 - i18n/dictionaries/no.json | 1 - i18n/dictionaries/sv.json | 1 - lib/trpc/memoizedRequests/index.ts | 4 +- server/routers/hotels/input.ts | 12 +--- server/routers/hotels/output.ts | 70 ++++++++----------- server/routers/hotels/query.ts | 60 +++++----------- stores/enter-details.ts | 2 +- .../enterDetails/bookingData.ts | 2 +- .../selectHotel/availabilityInput.ts | 4 +- .../selectHotel/hotePriceListProps.ts | 5 +- .../selectHotel/hotelCardListingProps.ts | 4 +- .../hotelReservation/selectHotel/map.ts | 4 +- .../selectHotel/priceCardProps.ts | 7 +- 27 files changed, 217 insertions(+), 227 deletions(-) diff --git a/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/@summary/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/@summary/page.tsx index f8c5f20ac..d3228e7b7 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/@summary/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/[step]/@summary/page.tsx @@ -71,20 +71,24 @@ export default async function SummaryPage({ price: availability.memberRate.localPrice.pricePerStay, currency: availability.memberRate.localPrice.currency, }, - euro: { - price: availability.memberRate.requestedPrice.pricePerStay, - currency: availability.memberRate.requestedPrice.currency, - }, + euro: availability.memberRate.requestedPrice + ? { + price: availability.memberRate.requestedPrice.pricePerStay, + currency: availability.memberRate.requestedPrice.currency, + } + : undefined, } : { local: { price: availability.publicRate.localPrice.pricePerStay, currency: availability.publicRate.localPrice.currency, }, - euro: { - price: availability.publicRate.requestedPrice.pricePerStay, - currency: availability.publicRate.requestedPrice.currency, - }, + euro: availability.publicRate.requestedPrice + ? { + price: availability.publicRate.requestedPrice.pricePerStay, + currency: availability.publicRate.requestedPrice.currency, + } + : undefined, } return ( diff --git a/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils.ts b/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils.ts index a021d9355..58b18a25d 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils.ts +++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils.ts @@ -9,8 +9,6 @@ import type { CategorizedFilters, Filter, } from "@/types/components/hotelReservation/selectHotel/hotelFilters" -import type { HotelPin } from "@/types/components/hotelReservation/selectHotel/map" -import { HotelListingEnum } from "@/types/enums/hotelListing" const hotelSurroundingsFilterNames = [ "Hotel surroundings", @@ -29,24 +27,8 @@ export async function fetchAvailableHotels( if (!availableHotels) throw new Error() const language = getLang() - const hotelMap = new Map() - availableHotels.availability.forEach((hotel) => { - const existingHotel = hotelMap.get(hotel.hotelId) - if (existingHotel) { - if (hotel.ratePlanSet === HotelListingEnum.RatePlanSet.PUBLIC) { - existingHotel.bestPricePerNight.regularAmount = - hotel.bestPricePerNight?.regularAmount - } else if (hotel.ratePlanSet === HotelListingEnum.RatePlanSet.MEMBER) { - existingHotel.bestPricePerNight.memberAmount = - hotel.bestPricePerNight?.memberAmount - } - } else { - hotelMap.set(hotel.hotelId, { ...hotel }) - } - }) - - const hotels = Array.from(hotelMap.values()).map(async (hotel) => { + const hotels = availableHotels.availability.map(async (hotel) => { const hotelData = await getHotelData({ hotelId: hotel.hotelId.toString(), language, @@ -56,7 +38,7 @@ export async function fetchAvailableHotels( return { hotelData: hotelData.data.attributes, - price: hotel.bestPricePerNight, + price: hotel.productType, } }) diff --git a/components/HotelReservation/EnterDetails/Summary/index.tsx b/components/HotelReservation/EnterDetails/Summary/index.tsx index fe297a55e..4b093f8ea 100644 --- a/components/HotelReservation/EnterDetails/Summary/index.tsx +++ b/components/HotelReservation/EnterDetails/Summary/index.tsx @@ -80,7 +80,9 @@ export default function Summary({ ) || { local: 0, euro: 0 } const roomsPriceLocal = room.localPrice.price + additionalPackageCost.local - const roomsPriceEuro = room.euroPrice.price + additionalPackageCost.euro + const roomsPriceEuro = room.euroPrice + ? room.euroPrice.price + additionalPackageCost.euro + : undefined useEffect(() => { setChosenBed(bedType) @@ -92,10 +94,15 @@ export default function Summary({ price: roomsPriceLocal + parseInt(breakfast.localPrice.totalPrice), currency: room.localPrice.currency, }, - euro: { - price: roomsPriceEuro + parseInt(breakfast.requestedPrice.totalPrice), - currency: room.euroPrice.currency, - }, + euro: + room.euroPrice && roomsPriceEuro + ? { + price: + roomsPriceEuro + + parseInt(breakfast.requestedPrice.totalPrice), + currency: room.euroPrice.currency, + } + : undefined, }) } else { setTotalPrice({ @@ -103,10 +110,13 @@ export default function Summary({ price: roomsPriceLocal, currency: room.localPrice.currency, }, - euro: { - price: roomsPriceEuro, - currency: room.euroPrice.currency, - }, + euro: + room.euroPrice && roomsPriceEuro + ? { + price: roomsPriceEuro, + currency: room.euroPrice.currency, + } + : undefined, }) } }, [ @@ -114,7 +124,7 @@ export default function Summary({ breakfast, roomsPriceLocal, room.localPrice.currency, - room.euroPrice.currency, + room.euroPrice, roomsPriceEuro, setTotalPrice, ]) @@ -269,16 +279,18 @@ export default function Summary({ } )} - - {intl.formatMessage({ id: "Approx." })}{" "} - {intl.formatMessage( - { id: "{amount} {currency}" }, - { - amount: intl.formatNumber(totalPrice.euro.price), - currency: totalPrice.euro.currency, - } - )} - + {totalPrice.euro && ( + + {intl.formatMessage({ id: "Approx." })}{" "} + {intl.formatMessage( + { id: "{amount} {currency}" }, + { + amount: intl.formatNumber(totalPrice.euro.price), + currency: totalPrice.euro.currency, + } + )} + + )} diff --git a/components/HotelReservation/HotelCard/HotelPriceList/HotelPriceCard/index.tsx b/components/HotelReservation/HotelCard/HotelPriceList/HotelPriceCard/index.tsx index 942f9fafe..3a5613ade 100644 --- a/components/HotelReservation/HotelCard/HotelPriceList/HotelPriceCard/index.tsx +++ b/components/HotelReservation/HotelCard/HotelPriceList/HotelPriceCard/index.tsx @@ -1,5 +1,6 @@ import { useIntl } from "react-intl" +import Divider from "@/components/TempDesignSystem/Divider" import Body from "@/components/TempDesignSystem/Text/Body" import Caption from "@/components/TempDesignSystem/Text/Caption" import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" @@ -9,15 +10,14 @@ import styles from "../hotelPriceList.module.css" import type { PriceCardProps } from "@/types/components/hotelReservation/selectHotel/priceCardProps" export default function HotelPriceCard({ - currency, - memberAmount, - regularAmount, + productTypePrices, + isMemberPrice = false, }: PriceCardProps) { const intl = useIntl() return (
- {memberAmount && ( + {isMemberPrice && (
@@ -30,7 +30,7 @@ export default function HotelPriceCard({
{intl.formatMessage({ id: "From" })} @@ -39,15 +39,15 @@ export default function HotelPriceCard({
- {memberAmount ? memberAmount : regularAmount} + {productTypePrices.localPrice.pricePerNight} - {currency} + {productTypePrices.localPrice.currency} /{intl.formatMessage({ id: "night" })} @@ -55,17 +55,40 @@ export default function HotelPriceCard({
- {/* TODO add correct local price when API change */} -
-
- - {intl.formatMessage({ id: "Approx." })} - -
-
- - EUR -
-
+ {productTypePrices?.requestedPrice && ( +
+
+ + {intl.formatMessage({ id: "Approx." })} + +
+
+ + {productTypePrices.requestedPrice.pricePerNight}{" "} + {productTypePrices.requestedPrice.currency} + +
+
+ )} + {productTypePrices.localPrice.pricePerStay !== + productTypePrices.localPrice.pricePerNight && ( + <> + +
+
+ + {intl.formatMessage({ id: "Total" })} + +
+
+ + {productTypePrices.localPrice.pricePerStay}{" "} + {productTypePrices.localPrice.currency} + +
+
+ + )}
) } diff --git a/components/HotelReservation/HotelCard/HotelPriceList/hotelPriceList.module.css b/components/HotelReservation/HotelCard/HotelPriceList/hotelPriceList.module.css index fe28eef93..bd81f1170 100644 --- a/components/HotelReservation/HotelCard/HotelPriceList/hotelPriceList.module.css +++ b/components/HotelReservation/HotelCard/HotelPriceList/hotelPriceList.module.css @@ -11,6 +11,17 @@ gap: var(--Spacing-x1); } +.prices { + display: flex; + flex-direction: column; + gap: var(--Spacing-x-one-and-half); + max-width: 260px; +} + +.divider { + margin: var(--Spacing-x-half) 0; +} + .priceRow { display: flex; justify-content: space-between; diff --git a/components/HotelReservation/HotelCard/HotelPriceList/index.tsx b/components/HotelReservation/HotelCard/HotelPriceList/index.tsx index 4167e044a..1f55c2d8a 100644 --- a/components/HotelReservation/HotelCard/HotelPriceList/index.tsx +++ b/components/HotelReservation/HotelCard/HotelPriceList/index.tsx @@ -1,6 +1,12 @@ +import { useParams } from "next/dist/client/components/navigation" import { useIntl } from "react-intl" +import { Lang } from "@/constants/languages" +import { selectRate } from "@/constants/routes/hotelReservation" + import { ErrorCircleIcon } from "@/components/Icons" +import Button from "@/components/TempDesignSystem/Button" +import Link from "@/components/TempDesignSystem/Link" import Body from "@/components/TempDesignSystem/Text/Body" import HotelPriceCard from "./HotelPriceCard" @@ -9,34 +15,52 @@ import styles from "./hotelPriceList.module.css" import { HotelPriceListProps } from "@/types/components/hotelReservation/selectHotel/hotePriceListProps" -export default function HotelPriceList({ price }: HotelPriceListProps) { +export default function HotelPriceList({ + price, + hotelId, +}: HotelPriceListProps) { const intl = useIntl() + const params = useParams() + const lang = params.lang as Lang return ( - <> +
{price ? ( <> - - + {price.public && } + {price.member && ( + + )} + ) : (
- +
+ +
{intl.formatMessage({ - id: "There are no rooms available that match your request", + id: "There are no rooms available that match your request.", })}
)} - +
) } diff --git a/components/HotelReservation/HotelCard/hotelCard.module.css b/components/HotelReservation/HotelCard/hotelCard.module.css index b20a7e30d..bfa87ea3a 100644 --- a/components/HotelReservation/HotelCard/hotelCard.module.css +++ b/components/HotelReservation/HotelCard/hotelCard.module.css @@ -70,13 +70,6 @@ gap: var(--Spacing-x-half); } -.prices { - display: flex; - flex-direction: column; - gap: var(--Spacing-x-one-and-half); - width: 100%; -} - .detailsButton { border-bottom: none; } diff --git a/components/HotelReservation/HotelCard/index.tsx b/components/HotelReservation/HotelCard/index.tsx index f996578c7..feda19a05 100644 --- a/components/HotelReservation/HotelCard/index.tsx +++ b/components/HotelReservation/HotelCard/index.tsx @@ -141,25 +141,7 @@ export default function HotelCard({ )} -
- - -
+ ) diff --git a/components/HotelReservation/HotelCardDialogListing/utils.ts b/components/HotelReservation/HotelCardDialogListing/utils.ts index 6183c5da4..ba40ccc3a 100644 --- a/components/HotelReservation/HotelCardDialogListing/utils.ts +++ b/components/HotelReservation/HotelCardDialogListing/utils.ts @@ -8,9 +8,9 @@ export function getHotelPins(hotels: HotelData[]): HotelPin[] { lng: hotel.hotelData.location.longitude, }, name: hotel.hotelData.name, - publicPrice: hotel.price?.regularAmount ?? null, - memberPrice: hotel.price?.memberAmount ?? null, - currency: hotel.price?.currency || null, + publicPrice: hotel.price?.public?.localPrice.pricePerNight ?? null, + memberPrice: hotel.price?.member?.localPrice.pricePerNight ?? null, + currency: hotel.price?.public?.localPrice.currency || null, images: [ hotel.hotelData.hotelContent.images, ...(hotel.hotelData.gallery?.heroImages ?? []), diff --git a/components/HotelReservation/HotelCardListing/index.tsx b/components/HotelReservation/HotelCardListing/index.tsx index c4a5a1eee..ab2d45d3e 100644 --- a/components/HotelReservation/HotelCardListing/index.tsx +++ b/components/HotelReservation/HotelCardListing/index.tsx @@ -12,6 +12,7 @@ import styles from "./hotelCardListing.module.css" import { type HotelCardListingProps, HotelCardListingTypeEnum, + type HotelData, } from "@/types/components/hotelReservation/selectHotel/hotelCardListingProps" import { SortOrder } from "@/types/components/hotelReservation/selectHotel/hotelSorter" @@ -43,10 +44,15 @@ export default function HotelCardListing({ (a.hotelData.ratings?.tripAdvisor.rating ?? 0) ) case SortOrder.Price: + const getPricePerNight = (hotel: HotelData): number => { + return ( + hotel.price?.member?.localPrice?.pricePerNight ?? + hotel.price?.public?.localPrice?.pricePerNight ?? + 0 + ) + } return [...hotelData].sort( - (a, b) => - parseInt(a.price?.memberAmount ?? "0", 10) - - parseInt(b.price?.memberAmount ?? "0", 10) + (a, b) => getPricePerNight(a) - getPricePerNight(b) ) case SortOrder.Distance: default: diff --git a/components/HotelReservation/SelectRate/Rooms/utils.ts b/components/HotelReservation/SelectRate/Rooms/utils.ts index 9d6f24e00..af80e1f4d 100644 --- a/components/HotelReservation/SelectRate/Rooms/utils.ts +++ b/components/HotelReservation/SelectRate/Rooms/utils.ts @@ -49,7 +49,7 @@ export function filterDuplicateRoomTypesByLowestPrice( const previousLowest = roomMap.get(roomType) const currentRequestedPrice = Math.min( - Number(publicRequestedPrice.pricePerNight) ?? Infinity, + Number(publicRequestedPrice?.pricePerNight) ?? Infinity, Number(memberRequestedPrice?.pricePerNight) ?? Infinity ) const currentLocalPrice = Math.min( diff --git a/i18n/dictionaries/de.json b/i18n/dictionaries/de.json index 02e7da88d..433a0ba33 100644 --- a/i18n/dictionaries/de.json +++ b/i18n/dictionaries/de.json @@ -348,7 +348,6 @@ "Terms and conditions": "Geschäftsbedingungen", "Thank you": "Danke", "Theatre": "Theater", - "There are no rooms available that match your request": "Es sind keine Zimmer verfügbar, die Ihrer Anfrage entsprechen", "There are no rooms available that match your request.": "Es sind keine Zimmer verfügbar, die Ihrer Anfrage entsprechen.", "There are no transactions to display": "Es sind keine Transaktionen zum Anzeigen vorhanden", "Things nearby HOTEL_NAME": "Dinge in der Nähe von {hotelName}", diff --git a/i18n/dictionaries/en.json b/i18n/dictionaries/en.json index 2263cf43f..38a5da82b 100644 --- a/i18n/dictionaries/en.json +++ b/i18n/dictionaries/en.json @@ -378,7 +378,6 @@ "Terms and conditions": "Terms and conditions", "Thank you": "Thank you", "Theatre": "Theatre", - "There are no rooms available that match your request": "There are no rooms available that match your request", "There are no rooms available that match your request.": "There are no rooms available that match your request.", "There are no transactions to display": "There are no transactions to display", "Things nearby HOTEL_NAME": "Things nearby {hotelName}", diff --git a/i18n/dictionaries/fi.json b/i18n/dictionaries/fi.json index 59097c54a..218abed13 100644 --- a/i18n/dictionaries/fi.json +++ b/i18n/dictionaries/fi.json @@ -350,7 +350,6 @@ "Terms and conditions": "Käyttöehdot", "Thank you": "Kiitos", "Theatre": "Teatteri", - "There are no rooms available that match your request": "Pyyntöäsi vastaavia huoneita ei ole saatavilla", "There are no rooms available that match your request.": "Ei huoneita saatavilla, jotka vastaavat pyyntöäsi.", "There are no transactions to display": "Näytettäviä tapahtumia ei ole", "Things nearby HOTEL_NAME": "Lähellä olevia asioita {hotelName}", diff --git a/i18n/dictionaries/no.json b/i18n/dictionaries/no.json index f5f131e8c..7cf8e985a 100644 --- a/i18n/dictionaries/no.json +++ b/i18n/dictionaries/no.json @@ -347,7 +347,6 @@ "Terms and conditions": "Vilkår og betingelser", "Thank you": "Takk", "Theatre": "Teater", - "There are no rooms available that match your request": "Det er ingen tilgjengelige rom som samsvarer med forespørselen din", "There are no rooms available that match your request.": "Det er ingen rom tilgjengelige som matcher din forespørsel.", "There are no transactions to display": "Det er ingen transaksjoner å vise", "Things nearby HOTEL_NAME": "Ting i nærheten av {hotelName}", diff --git a/i18n/dictionaries/sv.json b/i18n/dictionaries/sv.json index bca60e315..7f935f88a 100644 --- a/i18n/dictionaries/sv.json +++ b/i18n/dictionaries/sv.json @@ -347,7 +347,6 @@ "Terms and conditions": "Allmänna villkor", "Thank you": "Tack", "Theatre": "Teater", - "There are no rooms available that match your request": "Det finns inga tillgängliga rum som matchar din förfrågan", "There are no rooms available that match your request.": "Det finns inga rum tillgängliga som matchar din begäran.", "There are no transactions to display": "Det finns inga transaktioner att visa", "Things nearby HOTEL_NAME": "Saker i närheten av {hotelName}", diff --git a/lib/trpc/memoizedRequests/index.ts b/lib/trpc/memoizedRequests/index.ts index 407175703..4ab1aa5ea 100644 --- a/lib/trpc/memoizedRequests/index.ts +++ b/lib/trpc/memoizedRequests/index.ts @@ -82,7 +82,7 @@ export const getRoomAvailability = cache( roomStayStartDate, roomStayEndDate, children, - promotionCode, + bookingCode, rateCode, }: GetRoomsAvailabilityInput) { return serverClient().hotel.availability.rooms({ @@ -91,7 +91,7 @@ export const getRoomAvailability = cache( roomStayStartDate, roomStayEndDate, children, - promotionCode, + bookingCode, rateCode, }) } diff --git a/server/routers/hotels/input.ts b/server/routers/hotels/input.ts index 04bb16b17..9bfecaf6a 100644 --- a/server/routers/hotels/input.ts +++ b/server/routers/hotels/input.ts @@ -8,9 +8,7 @@ export const getHotelsAvailabilityInputSchema = z.object({ roomStayEndDate: z.string(), adults: z.number(), children: z.string().optional(), - promotionCode: z.string().optional().default(""), - reservationProfileType: z.string().optional().default(""), - attachedProfileId: z.string().optional().default(""), + bookingCode: z.string().optional().default(""), }) export const getRoomsAvailabilityInputSchema = z.object({ @@ -19,9 +17,7 @@ export const getRoomsAvailabilityInputSchema = z.object({ roomStayEndDate: z.string(), adults: z.number(), children: z.string().optional(), - promotionCode: z.string().optional(), - reservationProfileType: z.string().optional().default(""), - attachedProfileId: z.string().optional().default(""), + bookingCode: z.string().optional(), rateCode: z.string().optional(), }) @@ -31,9 +27,7 @@ export const getSelectedRoomAvailabilityInputSchema = z.object({ roomStayEndDate: z.string(), adults: z.number(), children: z.string().optional(), - promotionCode: z.string().optional(), - reservationProfileType: z.string().optional().default(""), - attachedProfileId: z.string().optional().default(""), + bookingCode: z.string().optional(), rateCode: z.string(), roomTypeCode: z.string(), packageCodes: z.array(z.nativeEnum(RoomPackageCodeEnum)).optional(), diff --git a/server/routers/hotels/output.ts b/server/routers/hotels/output.ts index 9bc81225e..b68e87fc0 100644 --- a/server/routers/hotels/output.ts +++ b/server/routers/hotels/output.ts @@ -491,22 +491,6 @@ const occupancySchema = z.object({ children: z.array(childrenSchema), }) -const bestPricePerStaySchema = z.object({ - currency: z.string(), - // TODO: remove optional when API is ready - regularAmount: z.string().optional(), - // TODO: remove optional when API is ready - memberAmount: z.string().optional(), -}) - -const bestPricePerNightSchema = z.object({ - currency: z.string(), - // TODO: remove optional when API is ready - regularAmount: z.string().optional(), - // TODO: remove optional when API is ready - memberAmount: z.string().optional(), -}) - const linksSchema = z.object({ links: z.array( z.object({ @@ -516,30 +500,6 @@ const linksSchema = z.object({ ), }) -const hotelsAvailabilitySchema = z.object({ - data: z.array( - z.object({ - attributes: z.object({ - checkInDate: z.string(), - checkOutDate: z.string(), - occupancy: occupancySchema.optional(), - status: z.string(), - hotelId: z.number(), - ratePlanSet: z.string().optional(), - bestPricePerStay: bestPricePerStaySchema.optional(), - bestPricePerNight: bestPricePerNightSchema.optional(), - }), - relationships: linksSchema.optional(), - type: z.string().optional(), - }) - ), -}) - -export const getHotelsAvailabilitySchema = hotelsAvailabilitySchema -export type HotelsAvailability = z.infer -export type HotelsAvailabilityPrices = - HotelsAvailability["data"][number]["attributes"]["bestPricePerNight"] - export const priceSchema = z.object({ pricePerNight: z.coerce.number(), pricePerStay: z.coerce.number(), @@ -550,7 +510,7 @@ export const productTypePriceSchema = z.object({ rateCode: z.string(), rateType: z.string().optional(), localPrice: priceSchema, - requestedPrice: priceSchema, + requestedPrice: priceSchema.optional(), }) const productSchema = z.object({ @@ -560,6 +520,34 @@ const productSchema = z.object({ }), }) +const hotelsAvailabilitySchema = z.object({ + data: z.array( + z.object({ + attributes: z.object({ + checkInDate: z.string(), + checkOutDate: z.string(), + occupancy: occupancySchema, + status: z.string(), + hotelId: z.number(), + productType: z + .object({ + public: productTypePriceSchema.optional(), + member: productTypePriceSchema.optional(), + }) + .optional(), + }), + relationships: linksSchema.optional(), + type: z.string().optional(), + }) + ), +}) + +export const getHotelsAvailabilitySchema = hotelsAvailabilitySchema +export type HotelsAvailability = z.infer +export type ProductType = + HotelsAvailability["data"][number]["attributes"]["productType"] +export type ProductTypePrices = z.infer + const roomConfigurationSchema = z.object({ status: z.string(), roomTypeCode: z.string(), diff --git a/server/routers/hotels/query.ts b/server/routers/hotels/query.ts index 28dd458d9..ea094de0f 100644 --- a/server/routers/hotels/query.ts +++ b/server/routers/hotels/query.ts @@ -369,9 +369,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, children, - promotionCode, - reservationProfileType, - attachedProfileId, + bookingCode, } = input const params: Record = { @@ -379,9 +377,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, ...(children && { children }), - promotionCode, - reservationProfileType, - attachedProfileId, + bookingCode, language: apiLang, } hotelsAvailabilityCounter.add(1, { @@ -390,8 +386,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, children, - promotionCode, - reservationProfileType, + bookingCode, }) console.info( "api.hotels.hotelsAvailability start", @@ -414,8 +409,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, children, - promotionCode, - reservationProfileType, + bookingCode, error_type: "http_error", error: JSON.stringify({ status: apiResponse.status, @@ -446,8 +440,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, children, - promotionCode, - reservationProfileType, + bookingCode, error_type: "validation_error", error: JSON.stringify(validateAvailabilityData.error), }) @@ -466,8 +459,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, children, - promotionCode, - reservationProfileType, + bookingCode, }) console.info( "api.hotels.hotelsAvailability success", @@ -493,9 +485,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, children, - promotionCode, - reservationProfileType, - attachedProfileId, + bookingCode, rateCode, } = input @@ -504,9 +494,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, ...(children && { children }), - promotionCode, - reservationProfileType, - attachedProfileId, + bookingCode, } roomsAvailabilityCounter.add(1, { @@ -515,8 +503,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, children, - promotionCode, - reservationProfileType, + bookingCode, }) console.info( "api.hotels.roomsAvailability start", @@ -540,8 +527,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, children, - promotionCode, - reservationProfileType, + bookingCode, error_type: "http_error", error: JSON.stringify({ status: apiResponse.status, @@ -572,8 +558,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, children, - promotionCode, - reservationProfileType, + bookingCode, error_type: "validation_error", error: JSON.stringify(validateAvailabilityData.error), }) @@ -592,8 +577,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, children, - promotionCode, - reservationProfileType, + bookingCode, }) console.info( "api.hotels.roomsAvailability success", @@ -620,9 +604,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, children, - promotionCode, - reservationProfileType, - attachedProfileId, + bookingCode, rateCode, roomTypeCode, packageCodes, @@ -633,9 +615,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, ...(children && { children }), - promotionCode, - reservationProfileType, - attachedProfileId, + bookingCode, language: toApiLang(ctx.lang), } @@ -645,8 +625,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, children, - promotionCode, - reservationProfileType, + bookingCode, }) console.info( "api.hotels.selectedRoomAvailability start", @@ -670,8 +649,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, children, - promotionCode, - reservationProfileType, + bookingCode, error_type: "http_error", error: JSON.stringify({ status: apiResponseAvailability.status, @@ -702,8 +680,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, children, - promotionCode, - reservationProfileType, + bookingCode, error_type: "validation_error", error: JSON.stringify(validateAvailabilityData.error), }) @@ -797,8 +774,7 @@ export const hotelQueryRouter = router({ roomStayEndDate, adults, children, - promotionCode, - reservationProfileType, + bookingCode, }) console.info( "api.hotels.selectedRoomAvailability success", diff --git a/stores/enter-details.ts b/stores/enter-details.ts index 374f1dc89..b5f99cc38 100644 --- a/stores/enter-details.ts +++ b/stores/enter-details.ts @@ -25,7 +25,7 @@ const SESSION_STORAGE_KEY = "enterDetails" type TotalPrice = { local: { price: number; currency: string } - euro: { price: number; currency: string } + euro?: { price: number; currency: string } } export interface EnterDetailsState { diff --git a/types/components/hotelReservation/enterDetails/bookingData.ts b/types/components/hotelReservation/enterDetails/bookingData.ts index 74ed4bda4..628fa3f8b 100644 --- a/types/components/hotelReservation/enterDetails/bookingData.ts +++ b/types/components/hotelReservation/enterDetails/bookingData.ts @@ -25,7 +25,7 @@ type Price = { export type RoomsData = { roomType: string localPrice: Price - euroPrice: Price + euroPrice: Price | undefined adults: number children?: Child[] cancellationText: string diff --git a/types/components/hotelReservation/selectHotel/availabilityInput.ts b/types/components/hotelReservation/selectHotel/availabilityInput.ts index 5b3a51b93..d8b7aad26 100644 --- a/types/components/hotelReservation/selectHotel/availabilityInput.ts +++ b/types/components/hotelReservation/selectHotel/availabilityInput.ts @@ -4,7 +4,5 @@ export type AvailabilityInput = { roomStayEndDate: string adults: number children?: string - promotionCode?: string - reservationProfileType?: string - attachedProfileId?: string + bookingCode?: string } diff --git a/types/components/hotelReservation/selectHotel/hotePriceListProps.ts b/types/components/hotelReservation/selectHotel/hotePriceListProps.ts index 2464fad43..4144abf45 100644 --- a/types/components/hotelReservation/selectHotel/hotePriceListProps.ts +++ b/types/components/hotelReservation/selectHotel/hotePriceListProps.ts @@ -1,5 +1,6 @@ -import type { HotelsAvailabilityPrices } from "@/server/routers/hotels/output" +import type { ProductType } from "@/server/routers/hotels/output" export type HotelPriceListProps = { - price: HotelsAvailabilityPrices + price: ProductType + hotelId: string } diff --git a/types/components/hotelReservation/selectHotel/hotelCardListingProps.ts b/types/components/hotelReservation/selectHotel/hotelCardListingProps.ts index 9c56f9949..68a6174ed 100644 --- a/types/components/hotelReservation/selectHotel/hotelCardListingProps.ts +++ b/types/components/hotelReservation/selectHotel/hotelCardListingProps.ts @@ -1,4 +1,4 @@ -import { HotelsAvailabilityPrices } from "@/server/routers/hotels/output" +import { ProductType } from "@/server/routers/hotels/output" import { Hotel } from "@/types/hotel" @@ -16,5 +16,5 @@ export type HotelCardListingProps = { export type HotelData = { hotelData: Hotel - price: HotelsAvailabilityPrices + price: ProductType } diff --git a/types/components/hotelReservation/selectHotel/map.ts b/types/components/hotelReservation/selectHotel/map.ts index 233fc2105..810dba573 100644 --- a/types/components/hotelReservation/selectHotel/map.ts +++ b/types/components/hotelReservation/selectHotel/map.ts @@ -29,8 +29,8 @@ type ImageMetaData = z.infer export type HotelPin = { name: string coordinates: Coordinates - publicPrice: string | null - memberPrice: string | null + publicPrice: number | null + memberPrice: number | null currency: string | null images: { imageSizes: ImageSizes diff --git a/types/components/hotelReservation/selectHotel/priceCardProps.ts b/types/components/hotelReservation/selectHotel/priceCardProps.ts index d339b4a06..a56a67d0f 100644 --- a/types/components/hotelReservation/selectHotel/priceCardProps.ts +++ b/types/components/hotelReservation/selectHotel/priceCardProps.ts @@ -1,5 +1,6 @@ +import { ProductTypePrices } from "@/server/routers/hotels/output" + export type PriceCardProps = { - currency: string - memberAmount?: string | undefined - regularAmount?: string | undefined + productTypePrices: ProductTypePrices + isMemberPrice?: boolean }