From eda475d64e9ddc6a62e2b4e6823d1abd97a9e380 Mon Sep 17 00:00:00 2001 From: Hrishikesh Vaipurkar Date: Mon, 24 Mar 2025 16:35:09 +0100 Subject: [PATCH] feat: SW-2028 Points validation redemption city search --- .../HotelReservation/HotelCard/index.tsx | 57 ++++++++++++++----- .../HotelCardListing/index.tsx | 2 + .../HotelReservation/SelectHotel/helpers.ts | 8 +++ .../HotelReservation/SelectHotel/index.tsx | 12 +++- 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 + .../selectHotel/hotelCardListingProps.ts | 1 + .../selectHotel/hotelCardProps.ts | 1 + 12 files changed, 71 insertions(+), 16 deletions(-) diff --git a/apps/scandic-web/components/HotelReservation/HotelCard/index.tsx b/apps/scandic-web/components/HotelReservation/HotelCard/index.tsx index d01f84e38..8a56c10be 100644 --- a/apps/scandic-web/components/HotelReservation/HotelCard/index.tsx +++ b/apps/scandic-web/components/HotelReservation/HotelCard/index.tsx @@ -18,6 +18,7 @@ import Link from "@/components/TempDesignSystem/Link" import Body from "@/components/TempDesignSystem/Text/Body" import Caption from "@/components/TempDesignSystem/Text/Caption" import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" +import { Tooltip } from "@/components/TempDesignSystem/Tooltip" import { mapApiImagesToGalleryImages } from "@/utils/imageGallery" import { getSingleDecimal } from "@/utils/numberFormatting" @@ -43,6 +44,7 @@ function HotelCard({ state = "default", type = HotelCardListingTypeEnum.PageListing, bookingCode = "", + userPoints, }: HotelCardProps) { const params = useParams() const lang = params.lang as Lang @@ -72,6 +74,15 @@ function HotelCard({ availability.productType?.member?.rateType === RateTypeEnum.Regular const price = availability.productType + const userHasEnoughPoints = + userPoints !== undefined + ? !!price?.redemptions?.some( + (r) => r.localPrice.pointsPerStay < userPoints + ) + : false + + const notEnoughPointsLabel = intl.formatMessage({ id: "Not enough points" }) + return (
) : null} - + + + ) : ( + + )} )} diff --git a/apps/scandic-web/components/HotelReservation/HotelCardListing/index.tsx b/apps/scandic-web/components/HotelReservation/HotelCardListing/index.tsx index 93af1cbed..0f644e393 100644 --- a/apps/scandic-web/components/HotelReservation/HotelCardListing/index.tsx +++ b/apps/scandic-web/components/HotelReservation/HotelCardListing/index.tsx @@ -30,6 +30,7 @@ import { RateTypeEnum } from "@/types/enums/rateType" export default function HotelCardListing({ hotelData, type = HotelCardListingTypeEnum.PageListing, + userPoints, }: HotelCardListingProps) { const { data: session } = useSession() const isUserLoggedIn = isValidClientSession(session) @@ -121,6 +122,7 @@ export default function HotelCardListing({ } type={type} bookingCode={bookingCode} + userPoints={userPoints} /> )) diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/helpers.ts b/apps/scandic-web/components/HotelReservation/SelectHotel/helpers.ts index 1a6f79c24..5b2cc97bb 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/helpers.ts +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/helpers.ts @@ -246,6 +246,14 @@ export async function getHotels( return hotels } +export async function getUserPoints() { + const membershipCard = await serverClient().user.safeMembershipLevel() + if (!membershipCard) { + return undefined + } + return membershipCard.currentPoints +} + const hotelSurroundingsFilterNames = [ "Hotel surroundings", "Hotel omgivelser", diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/index.tsx b/apps/scandic-web/components/HotelReservation/SelectHotel/index.tsx index af8528438..23e772916 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/index.tsx @@ -23,7 +23,7 @@ import { convertObjToSearchParams } from "@/utils/url" import HotelCardListing from "../HotelCardListing" import BookingCodeFilter from "./BookingCodeFilter" -import { getFiltersFromHotels, getHotels } from "./helpers" +import { getFiltersFromHotels, getHotels, getUserPoints } from "./helpers" import HotelCount from "./HotelCount" import HotelFilter from "./HotelFilter" import HotelSorter from "./HotelSorter" @@ -76,6 +76,11 @@ export default async function SelectHotel({ !!redemption ) + let userPoints + if (redemption) { + userPoints = await getUserPoints() + } + const arrivalDate = new Date(selectHotelParams.fromDate) const departureDate = new Date(selectHotelParams.toDate) @@ -247,7 +252,10 @@ export default async function SelectHotel({ isAllUnavailable={isAllUnavailable} operaId={hotels?.[0]?.hotel.operaId} /> - + diff --git a/apps/scandic-web/i18n/dictionaries/da.json b/apps/scandic-web/i18n/dictionaries/da.json index 91a015622..d4ed19aa6 100644 --- a/apps/scandic-web/i18n/dictionaries/da.json +++ b/apps/scandic-web/i18n/dictionaries/da.json @@ -539,6 +539,7 @@ "Non refundable": "Ikke-refunderbart", "Non-refundable": "Ikke-refunderbart", "Nordic Swan Ecolabel": "Svanemærket", + "Not enough points": "Ikke nok point", "Not found": "Ikke fundet", "Not included": "Ikke inkluderet", "Number of charging points for electric cars: {number}": "Antal ladepunkter til elbiler: {number}", diff --git a/apps/scandic-web/i18n/dictionaries/de.json b/apps/scandic-web/i18n/dictionaries/de.json index 190337481..1b73d0b1c 100644 --- a/apps/scandic-web/i18n/dictionaries/de.json +++ b/apps/scandic-web/i18n/dictionaries/de.json @@ -540,6 +540,7 @@ "Non refundable": "Nicht erstattungsfähig", "Non-refundable": "Nicht erstattungsfähig", "Nordic Swan Ecolabel": "Nordic Swan Ecolabel", + "Not enough points": "Nicht genügend Punkte", "Not found": "Nicht gefunden", "Not included": "Nicht inbegriffen", "Number of charging points for electric cars: {number}": "Anzahl der Ladestationen für Elektroautos: {number}", diff --git a/apps/scandic-web/i18n/dictionaries/en.json b/apps/scandic-web/i18n/dictionaries/en.json index 882d6b794..3c5d32adb 100644 --- a/apps/scandic-web/i18n/dictionaries/en.json +++ b/apps/scandic-web/i18n/dictionaries/en.json @@ -538,6 +538,7 @@ "Non refundable": "Non refundable", "Non-refundable": "Non-refundable", "Nordic Swan Ecolabel": "Nordic Swan Ecolabel", + "Not enough points": "Not enough points", "Not found": "Not found", "Not included": "Not included", "Number of charging points for electric cars: {number}": "Number of charging points for electric cars: {number}", diff --git a/apps/scandic-web/i18n/dictionaries/fi.json b/apps/scandic-web/i18n/dictionaries/fi.json index a9719d3ca..77fffb6fc 100644 --- a/apps/scandic-web/i18n/dictionaries/fi.json +++ b/apps/scandic-web/i18n/dictionaries/fi.json @@ -539,6 +539,7 @@ "Non refundable": "Ei palautettavissa", "Non-refundable": "Ei palautettavissa", "Nordic Swan Ecolabel": "Ympäristömerkki Miljömärkt", + "Not enough points": "Pisteet eivät riitä", "Not found": "Ei löydetty", "Not included": "Ei sisälly", "Number of charging points for electric cars: {number}": "Sähköautojen latauspisteiden määrä: {number}", diff --git a/apps/scandic-web/i18n/dictionaries/no.json b/apps/scandic-web/i18n/dictionaries/no.json index 3eb860260..1a375f2a5 100644 --- a/apps/scandic-web/i18n/dictionaries/no.json +++ b/apps/scandic-web/i18n/dictionaries/no.json @@ -538,6 +538,7 @@ "Non refundable": "Ikke-refunderbart", "Non-refundable": "Ikke-refunderbart", "Nordic Swan Ecolabel": "Svanemerket", + "Not enough points": "Ikke nok poeng", "Not found": "Ikke funnet", "Not included": "Ikke inkludert", "Number of charging points for electric cars: {number}": "Antall ladepunkter for elbiler: {number}", diff --git a/apps/scandic-web/i18n/dictionaries/sv.json b/apps/scandic-web/i18n/dictionaries/sv.json index f4e343ce9..d30dda063 100644 --- a/apps/scandic-web/i18n/dictionaries/sv.json +++ b/apps/scandic-web/i18n/dictionaries/sv.json @@ -538,6 +538,7 @@ "Non refundable": "Ej återbetalningsbar", "Non-refundable": "Ej återbetalningsbar", "Nordic Swan Ecolabel": "Svanenmärkt", + "Not enough points": "Inte tillräckligt antal poäng", "Not found": "Hittades inte", "Not included": "Ej inkluderat", "Number of charging points for electric cars: {number}": "Antal laddplatser för elbilar: {number}", diff --git a/apps/scandic-web/types/components/hotelReservation/selectHotel/hotelCardListingProps.ts b/apps/scandic-web/types/components/hotelReservation/selectHotel/hotelCardListingProps.ts index f32fe58de..5db3c0a0c 100644 --- a/apps/scandic-web/types/components/hotelReservation/selectHotel/hotelCardListingProps.ts +++ b/apps/scandic-web/types/components/hotelReservation/selectHotel/hotelCardListingProps.ts @@ -15,6 +15,7 @@ export type HotelData = { export type HotelCardListingProps = { hotelData: HotelResponse[] type?: HotelCardListingTypeEnum + userPoints?: number } export interface NullableHotelData extends Omit { diff --git a/apps/scandic-web/types/components/hotelReservation/selectHotel/hotelCardProps.ts b/apps/scandic-web/types/components/hotelReservation/selectHotel/hotelCardProps.ts index 1c6fe8542..8a2151292 100644 --- a/apps/scandic-web/types/components/hotelReservation/selectHotel/hotelCardProps.ts +++ b/apps/scandic-web/types/components/hotelReservation/selectHotel/hotelCardProps.ts @@ -7,4 +7,5 @@ export type HotelCardProps = { type?: HotelCardListingTypeEnum state?: "default" | "active" bookingCode?: string | null + userPoints?: number }