Merged in feat/SW-3526-show-sas-eb-points-rate-in- (pull request #2933)

feat(SW-3526): Show EB points rate and label in booking flow

* feat(SW-3526): Show EB points rate and label in booking flow

* feat(SW-3526) Optimized points currency code

* feat(SW-3526) Removed extra multiplication for token expiry after rebase

* feat(SW-3526): Updated to exhaustive check and thow if type error

Approved-by: Anton Gunnarsson
This commit is contained in:
Hrishikesh Vaipurkar
2025-10-15 06:54:44 +00:00
parent 73af1eed9b
commit 78ede453a2
27 changed files with 281 additions and 176 deletions

View File

@@ -12,6 +12,7 @@ import { useScrollToTop } from "@scandic-hotels/common/hooks/useScrollToTop"
import { BackToTopButton } from "@scandic-hotels/design-system/BackToTopButton"
import { HotelCard } from "@scandic-hotels/design-system/HotelCard"
import { useGetPointsCurrency } from "../../bookingFlowConfig/bookingFlowConfigContext"
import { useIsLoggedIn } from "../../hooks/useIsLoggedIn"
import useLang from "../../hooks/useLang"
import { mapApiImagesToGalleryImages } from "../../misc/imageGallery"
@@ -57,6 +58,7 @@ export default function HotelCardListing({
const { activeHotel, activate, disengage, engage } = useHotelsMapStore()
const { showBackToTop, scrollToTop } = useScrollToTop({ threshold: 490 })
const activeCardRef = useRef<HTMLDivElement | null>(null)
const pointsCurrency = useGetPointsCurrency()
const sortBy = searchParams.get("sort") ?? DEFAULT_SORT
@@ -159,6 +161,7 @@ export default function HotelCardListing({
tripAdvisor: hotel.hotel.ratings?.tripAdvisor.rating,
},
}}
pointsCurrency={pointsCurrency}
lang={lang}
fullPrice={!hotel.availability.bookingCode}
prices={

View File

@@ -16,6 +16,7 @@ import { OldDSButton as Button } from "@scandic-hotels/design-system/OldDSButton
import Subtitle from "@scandic-hotels/design-system/Subtitle"
import { Typography } from "@scandic-hotels/design-system/Typography"
import { useGetPointsCurrency } from "../../bookingFlowConfig/bookingFlowConfigContext"
import { useIsLoggedIn } from "../../hooks/useIsLoggedIn"
import useLang from "../../hooks/useLang"
@@ -34,6 +35,7 @@ export default function ListingHotelCardDialog({
}: ListingHotelCardProps) {
const intl = useIntl()
const lang = useLang()
const pointsCurrency = useGetPointsCurrency()
const [imageError, setImageError] = useState(false)
@@ -153,7 +155,10 @@ export default function ListingHotelCardDialog({
</Subtitle>
)}
{redemptionPrice && (
<HotelPointsRow pointsPerStay={redemptionPrice} />
<HotelPointsRow
pointsPerStay={redemptionPrice}
pointsCurrency={pointsCurrency}
/>
)}
{chequePrice && (
<Subtitle type="two">

View File

@@ -1,14 +1,16 @@
"use client"
import { useIntl } from "react-intl"
import { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
import { formatPrice } from "@scandic-hotels/common/utils/numberFormatting"
import { useGetPointsCurrency } from "../../../../../bookingFlowConfig/bookingFlowConfigContext"
import BoldRow from "../Bold"
import RegularRow from "../Regular"
import BedTypeRow from "./BedType"
import PackagesRow from "./Packages"
import type { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
import type { SharedPriceRowProps } from "./price"
export interface RedemptionPriceType {
@@ -34,6 +36,7 @@ export default function RedemptionPrice({
price,
}: RedemptionPriceProps) {
const intl = useIntl()
const pointsCurrency = useGetPointsCurrency()
if (!price) {
return null
@@ -50,7 +53,7 @@ export default function RedemptionPrice({
: null
const additionalCurrency = price.currency ?? currency
let averagePricePerNight = `${price.pointsPerNight} ${CurrencyEnum.POINTS}`
let averagePricePerNight = `${price.pointsPerNight} ${pointsCurrency}`
if (averageAdditionalPricePerNight) {
averagePricePerNight = `${averagePricePerNight} + ${averageAdditionalPricePerNight} ${additionalCurrency}`
}
@@ -62,7 +65,7 @@ export default function RedemptionPrice({
value={formatPrice(
intl,
price.pointsPerStay,
CurrencyEnum.POINTS,
pointsCurrency,
additionalPricePerStay,
additionalCurrency
)}

View File

@@ -19,6 +19,7 @@ import { InteractiveMap } from "@scandic-hotels/design-system/Map/InteractiveMap
import { Typography } from "@scandic-hotels/design-system/Typography"
import { trackEvent } from "@scandic-hotels/tracking/base"
import { useGetPointsCurrency } from "../../../../bookingFlowConfig/bookingFlowConfigContext"
import { useIsLoggedIn } from "../../../../hooks/useIsLoggedIn"
import useLang from "../../../../hooks/useLang"
import { mapApiImagesToGalleryImages } from "../../../../misc/imageGallery"
@@ -76,6 +77,7 @@ export function SelectHotelMapContent({
const activeFilters = useHotelFilterStore((state) => state.activeFilters)
const setResultCount = useHotelFilterStore((state) => state.setResultCount)
const pointsCurrency = useGetPointsCurrency()
const hotelMapStore = useHotelsMapStore()
@@ -254,6 +256,7 @@ export function SelectHotelMapContent({
)}
</div>
<InteractiveMap
pointsCurrency={pointsCurrency}
closeButton={closeButton}
coordinates={coordinates}
hotelPins={filteredHotelPins.map((pin) => {

View File

@@ -3,6 +3,7 @@ import { useIntl } from "react-intl"
import PointsRateCard from "@scandic-hotels/design-system/PointsRateCard"
import { useGetPointsCurrency } from "../../../../../../../bookingFlowConfig/bookingFlowConfigContext"
import { useSelectRateContext } from "../../../../../../../contexts/SelectRate/SelectRateContext"
import { BookingCodeFilterEnum } from "../../../../../../../stores/bookingCode-filter"
import { sumPackages } from "../../../../../../../utils/SelectRate"
@@ -33,6 +34,7 @@ export default function Redemptions({
actions: { selectRate },
selectedRates,
} = useSelectRateContext()
const pointsCurrency = useGetPointsCurrency()
// TODO: Replace with context value when we have support for dropdown "Show all rates"
const selectedFilter = BookingCodeFilterEnum.All as BookingCodeFilterEnum
@@ -86,7 +88,7 @@ export default function Redemptions({
price: additionalPrice.toString(),
}
: undefined,
currency: "PTS",
currency: pointsCurrency ?? "PTS",
isDisabled: !r.redemption.hasEnoughPoints,
points: r.redemption.localPrice.pointsPerStay.toString(),
rateCode: r.redemption.rateCode,