From 5058180c41c9d28e720785eff0b8802633560a25 Mon Sep 17 00:00:00 2001 From: Hrishikesh Vaipurkar Date: Mon, 3 Mar 2025 16:39:10 +0100 Subject: [PATCH] feat: SW-1583 Implemented Reward nights on city search --- .../(standard)/select-hotel/utils.ts | 5 +-- .../hotelreservation/(standard)/utils.ts | 2 ++ .../app/[lang]/(live)/(public)/login/route.ts | 2 +- .../(live)/(public)/verifymagiclink/route.ts | 8 ++++- .../hotelPointsCard.module.css | 5 +++ .../HotelCard/HotelPointsCard/index.tsx | 36 +++++++++++++++++++ .../HotelCard/hotelCard.module.css | 6 ++++ .../HotelReservation/HotelCard/index.tsx | 19 +++++++++- .../HotelReservation/SelectHotel/index.tsx | 3 ++ apps/scandic-web/i18n/dictionaries/da.json | 1 + apps/scandic-web/i18n/dictionaries/de.json | 1 + apps/scandic-web/i18n/dictionaries/en.json | 1 + apps/scandic-web/i18n/dictionaries/fi.json | 1 + apps/scandic-web/i18n/dictionaries/no.json | 1 + apps/scandic-web/i18n/dictionaries/sv.json | 1 + apps/scandic-web/middlewares/bookingFlow.ts | 26 ++++++++++++++ .../server/routers/hotels/input.ts | 1 + .../server/routers/hotels/query.ts | 22 ++++++++++-- .../schemas/availability/productType.ts | 8 ++++- .../hotels/schemas/productTypePrice.ts | 19 ++++++++-- .../selectHotel/availabilityInput.ts | 2 ++ .../selectHotel/priceCardProps.ts | 9 ++++- .../selectHotel/selectHotelSearchParams.ts | 2 ++ .../hotelReservation/selectRate/selectRate.ts | 1 + .../types/trpc/routers/hotel/availability.ts | 6 +++- 25 files changed, 176 insertions(+), 12 deletions(-) create mode 100644 apps/scandic-web/components/HotelReservation/HotelCard/HotelPointsCard/hotelPointsCard.module.css create mode 100644 apps/scandic-web/components/HotelReservation/HotelCard/HotelPointsCard/index.tsx diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils.ts b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils.ts index d54df6248..9b61a5351 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils.ts +++ b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils.ts @@ -36,8 +36,9 @@ const hotelFacilitiesFilterNames = [ export async function fetchAvailableHotels( input: AvailabilityInput ): Promise { - const availableHotels = - await serverClient().hotel.availability.hotelsByCity(input) + const availableHotels = input.redemption + ? await serverClient().hotel.availability.hotelsByCityWithRedemption(input) + : await serverClient().hotel.availability.hotelsByCity(input) if (!availableHotels) return [] diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/utils.ts b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/utils.ts index 6fa32bdfb..e38f4c759 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/utils.ts +++ b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/utils.ts @@ -28,6 +28,7 @@ interface HotelSearchDetails { childrenInRoomString?: string childrenInRoom?: Child[] bookingCode?: string + redemption?: boolean } export async function getHotelSearchDetails< @@ -105,5 +106,6 @@ export async function getHotelSearchDetails< childrenInRoomString, childrenInRoom, bookingCode: selectHotelParams.bookingCode ?? undefined, + redemption: selectHotelParams.searchType === "redemption", } } diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/login/route.ts b/apps/scandic-web/app/[lang]/(live)/(public)/login/route.ts index bca37a262..4ee4ce565 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/login/route.ts +++ b/apps/scandic-web/app/[lang]/(live)/(public)/login/route.ts @@ -117,7 +117,7 @@ export async function GET( /** Record is next-auth typings */ const params: Record = { ui_locales: context.params.lang, - scope: ["openid", "profile", "booking", "profile_link"], + scope: ["openid", "profile", "booking", "profile_link", "availability"], /** * The `acr_values` param is used to make Curity display the proper login * page for Scandic. Without the parameter Curity presents some choices diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/verifymagiclink/route.ts b/apps/scandic-web/app/[lang]/(live)/(public)/verifymagiclink/route.ts index 7f092cc01..bb95fbe87 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/verifymagiclink/route.ts +++ b/apps/scandic-web/app/[lang]/(live)/(public)/verifymagiclink/route.ts @@ -65,7 +65,13 @@ export async function GET( }, { ui_locales: context.params.lang, - scope: ["openid", "profile"].join(" "), + scope: [ + "openid", + "profile", + "booking", + "availability", + "profile_link", + ].join(" "), loginKey: loginKey, for_origin: publicURL, acr_values: "urn:com:scandichotels:scandic-email", diff --git a/apps/scandic-web/components/HotelReservation/HotelCard/HotelPointsCard/hotelPointsCard.module.css b/apps/scandic-web/components/HotelReservation/HotelCard/HotelPointsCard/hotelPointsCard.module.css new file mode 100644 index 000000000..8dd8ad39a --- /dev/null +++ b/apps/scandic-web/components/HotelReservation/HotelCard/HotelPointsCard/hotelPointsCard.module.css @@ -0,0 +1,5 @@ +.poinstRow { + display: flex; + gap: var(--Spacing-x1); + align-items: baseline; +} diff --git a/apps/scandic-web/components/HotelReservation/HotelCard/HotelPointsCard/index.tsx b/apps/scandic-web/components/HotelReservation/HotelCard/HotelPointsCard/index.tsx new file mode 100644 index 000000000..a8ba871d5 --- /dev/null +++ b/apps/scandic-web/components/HotelReservation/HotelCard/HotelPointsCard/index.tsx @@ -0,0 +1,36 @@ +import { useIntl } from "react-intl" + +import Caption from "@/components/TempDesignSystem/Text/Caption" +import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" + +import styles from "./hotelPointsCard.module.css" + +import type { PointsCardProps } from "@/types/components/hotelReservation/selectHotel/priceCardProps" + +export default function HotelPointsCard({ + productTypePoints, +}: PointsCardProps) { + const intl = useIntl() + + return ( +
+ + {productTypePoints.localPrice.pointsPerStay} + + + {intl.formatMessage({ id: "Points" })} + + {productTypePoints.localPrice.pricePerStay ? ( + <> + + + + {productTypePoints.localPrice.pricePerStay} + + + {productTypePoints.localPrice.currency} + + + ) : null} +
+ ) +} diff --git a/apps/scandic-web/components/HotelReservation/HotelCard/hotelCard.module.css b/apps/scandic-web/components/HotelReservation/HotelCard/hotelCard.module.css index 06b8e50c5..4d0923131 100644 --- a/apps/scandic-web/components/HotelReservation/HotelCard/hotelCard.module.css +++ b/apps/scandic-web/components/HotelReservation/HotelCard/hotelCard.module.css @@ -96,6 +96,12 @@ text-decoration: line-through; } +.pointsCard { + background-color: var(--Base-Surface-Secondary-light-Normal); + padding: var(--Spacing-x-one-and-half); + border-radius: var(--Corner-radius-Medium); +} + @media screen and (min-width: 768px) and (max-width: 1024px) { .imageContainer { height: 180px; diff --git a/apps/scandic-web/components/HotelReservation/HotelCard/index.tsx b/apps/scandic-web/components/HotelReservation/HotelCard/index.tsx index 361cfcc78..b7eada1ce 100644 --- a/apps/scandic-web/components/HotelReservation/HotelCard/index.tsx +++ b/apps/scandic-web/components/HotelReservation/HotelCard/index.tsx @@ -22,6 +22,7 @@ import { getSingleDecimal } from "@/utils/numberFormatting" import ReadMore from "../ReadMore" import TripAdvisorChip from "../TripAdvisorChip" +import HotelPointsCard from "./HotelPointsCard" import HotelPriceCard from "./HotelPriceCard" import NoPriceAvailableCard from "./NoPriceAvailableCard" import { hotelCardVariants } from "./variants" @@ -172,7 +173,9 @@ function HotelCard({ {bookingCode} )} - {(!isUserLoggedIn || (bookingCode && !fullPrice)) && + {(!isUserLoggedIn || + !price.member || + (bookingCode && !fullPrice)) && price.public && ( )} @@ -182,6 +185,20 @@ function HotelCard({ isMemberPrice /> )} + {price.redemption && ( +
+ + {intl.formatMessage({ id: "Available rates" })} + + + {price.redemptionA && ( + + )} + {price.redemptionB && ( + + )} +
+ )}