Merged in fix/SW-2249-missing-currency (pull request #2159)

fix(SW-2249): Added default currency to summary and price details modal

* fix(SW-2249): Added default currency to summary and price details modal


Approved-by: Hrishikesh Vaipurkar
This commit is contained in:
Tobias Johansson
2025-05-26 06:51:57 +00:00
parent 2ddf31cbed
commit f77202f58b
13 changed files with 77 additions and 67 deletions

View File

@@ -132,6 +132,7 @@ export default function PriceDetails() {
toDate={checkOutDate}
totalPrice={totalPrice}
vat={vat}
defaultCurrency={currency}
/>
)
}

View File

@@ -13,12 +13,14 @@ export default function DesktopSummary({ isMember }: SummaryProps) {
(state) => state.actions.toggleSummaryOpen
)
const { booking, rooms, totalPrice, vat } = useEnterDetailsStore((state) => ({
booking: state.booking,
rooms: state.rooms,
totalPrice: state.totalPrice,
vat: state.vat,
}))
const { booking, rooms, totalPrice, vat, defaultCurrency } =
useEnterDetailsStore((state) => ({
booking: state.booking,
rooms: state.rooms,
totalPrice: state.totalPrice,
vat: state.vat,
defaultCurrency: state.defaultCurrency,
}))
return (
<SidePanel variant="summary">
@@ -29,6 +31,7 @@ export default function DesktopSummary({ isMember }: SummaryProps) {
totalPrice={totalPrice}
vat={vat}
toggleSummaryOpen={toggleSummaryOpen}
defaultCurrency={defaultCurrency}
/>
</SidePanel>
)

View File

@@ -19,12 +19,14 @@ export default function MobileSummary({ isMember }: SummaryProps) {
})
)
const { booking, rooms, totalPrice, vat } = useEnterDetailsStore((state) => ({
booking: state.booking,
rooms: state.rooms,
totalPrice: state.totalPrice,
vat: state.vat,
}))
const { booking, rooms, totalPrice, vat, defaultCurrency } =
useEnterDetailsStore((state) => ({
booking: state.booking,
rooms: state.rooms,
totalPrice: state.totalPrice,
vat: state.vat,
defaultCurrency: state.defaultCurrency,
}))
const showPromo =
!isMember &&
@@ -58,6 +60,7 @@ export default function MobileSummary({ isMember }: SummaryProps) {
totalPrice={totalPrice}
vat={vat}
toggleSummaryOpen={toggleSummaryOpen}
defaultCurrency={defaultCurrency}
/>
</div>
</SummaryBottomSheet>

View File

@@ -28,14 +28,6 @@ import styles from "./ui.module.css"
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
import type { RoomRate } from "@/types/components/hotelReservation/enterDetails/details"
import type { EnterDetailsSummaryProps } from "@/types/components/hotelReservation/summary"
import { CurrencyEnum } from "@/types/enums/currency"
const notDisplayableCurrencies = [
CurrencyEnum.CC,
CurrencyEnum.POINTS,
CurrencyEnum.Voucher,
CurrencyEnum.Unknown,
]
export default function SummaryUI({
booking,
@@ -44,6 +36,7 @@ export default function SummaryUI({
isMember,
vat,
toggleSummaryOpen,
defaultCurrency,
}: EnterDetailsSummaryProps) {
const intl = useIntl()
const lang = useLang()
@@ -190,10 +183,6 @@ export default function SummaryUI({
const guests = guestsParts.join(", ")
const hideBedCurrency = notDisplayableCurrencies.includes(
room.roomPrice.perStay.local.currency
)
let rateDetails = room.rateDetails
if (room.memberRateDetails) {
if (isMember || room.guest.join) {
@@ -201,6 +190,8 @@ export default function SummaryUI({
}
}
const zeroPrice = formatPrice(intl, 0, defaultCurrency)
return (
<Fragment key={idx}>
<div
@@ -314,15 +305,7 @@ export default function SummaryUI({
{room.bedType.description}
</Body>
<Body color="uiTextHighContrast">
{formatPrice(
intl,
0,
hideBedCurrency
? ""
: room.roomPrice.perStay.local.currency
)}
</Body>
<Body color="uiTextHighContrast">{zeroPrice}</Body>
</div>
) : null}
{childBedCrib ? (
@@ -342,13 +325,7 @@ export default function SummaryUI({
})}
</Caption>
</div>
<Body color="uiTextHighContrast">
{formatPrice(
intl,
0,
room.roomPrice.perStay.local.currency
)}
</Body>
<Body color="uiTextHighContrast">{zeroPrice}</Body>
</div>
) : null}
{childBedExtraBed ? (
@@ -365,13 +342,7 @@ export default function SummaryUI({
)}
</Body>
</div>
<Body color="uiTextHighContrast">
{formatPrice(
intl,
0,
room.roomPrice.perStay.local.currency
)}
</Body>
<Body color="uiTextHighContrast">{zeroPrice}</Body>
</div>
) : null}
<Breakfast
@@ -405,6 +376,7 @@ export default function SummaryUI({
toDate={booking.toDate}
totalPrice={totalPrice}
vat={vat}
defaultCurrency={defaultCurrency}
/>
</div>
<div>

View File

@@ -36,6 +36,7 @@ export default function PriceDetails() {
toDate={toDate}
totalPrice={totalPrice}
vat={bookedRoom.vatPercentage}
defaultCurrency={bookedRoom.currencyCode}
/>
</div>
)

View File

@@ -31,6 +31,7 @@ import type { BreakfastPackage } from "@/types/components/hotelReservation/break
import type { BedTypeSchema } from "@/types/components/hotelReservation/enterDetails/bedType"
import type { Price } from "@/types/components/hotelReservation/price"
import type { Child } from "@/types/components/hotelReservation/selectRate/selectRate"
import type { CurrencyEnum } from "@/types/enums/currency"
import type { Package, Packages } from "@/types/requests/packages"
type RoomPrice =
@@ -59,6 +60,7 @@ export interface PriceDetailsTableProps {
toDate: string
totalPrice: Price
vat: number
defaultCurrency: CurrencyEnum
}
export default function PriceDetailsTable({
@@ -69,6 +71,7 @@ export default function PriceDetailsTable({
toDate,
totalPrice,
vat,
defaultCurrency,
}: PriceDetailsTableProps) {
const intl = useIntl()
const lang = useLang()
@@ -122,11 +125,7 @@ export default function PriceDetailsTable({
}
if (!currency) {
if (room.packages?.length) {
currency = room.packages[0].localPrice.currency
} else if (room.breakfast) {
currency = room.breakfast.localPrice.currency
}
currency = defaultCurrency
}
if (!price && !voucherPrice && !chequePrice && !redemptionPrice) {

View File

@@ -36,7 +36,10 @@ export default function Summary({
vat,
toggleSummaryOpen,
}: SelectRateSummaryProps) {
const rateSummary = useRatesStore((state) => state.rateSummary)
const { rateSummary, defaultCurrency } = useRatesStore((state) => ({
rateSummary: state.rateSummary,
defaultCurrency: state.defaultCurrency,
}))
const intl = useIntl()
const lang = useLang()
@@ -153,6 +156,7 @@ export default function Summary({
}
const roomPackages = room.packages
const zeroPrice = formatPrice(intl, 0, defaultCurrency)
return (
<Fragment key={idx}>
@@ -247,13 +251,7 @@ export default function Summary({
})}
</Caption>
</div>
<Body color="uiTextHighContrast">
{formatPrice(
intl,
0,
room.roomPrice.perStay.local.currency
)}
</Body>
<Body color="uiTextHighContrast">{zeroPrice}</Body>
</div>
) : null}
{childBedExtraBed ? (
@@ -270,13 +268,7 @@ export default function Summary({
)}
</Body>
</div>
<Body color="uiTextHighContrast">
{formatPrice(
intl,
0,
room.roomPrice.perStay.local.currency
)}
</Body>
<Body color="uiTextHighContrast">{zeroPrice}</Body>
</div>
) : null}
{roomPackages?.map((pkg) => (
@@ -317,6 +309,7 @@ export default function Summary({
toDate={booking.toDate}
totalPrice={totalPrice}
vat={vat}
defaultCurrency={defaultCurrency}
/>
</div>
<div>