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:
@@ -132,6 +132,7 @@ export default function PriceDetails() {
|
|||||||
toDate={checkOutDate}
|
toDate={checkOutDate}
|
||||||
totalPrice={totalPrice}
|
totalPrice={totalPrice}
|
||||||
vat={vat}
|
vat={vat}
|
||||||
|
defaultCurrency={currency}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,12 +13,14 @@ export default function DesktopSummary({ isMember }: SummaryProps) {
|
|||||||
(state) => state.actions.toggleSummaryOpen
|
(state) => state.actions.toggleSummaryOpen
|
||||||
)
|
)
|
||||||
|
|
||||||
const { booking, rooms, totalPrice, vat } = useEnterDetailsStore((state) => ({
|
const { booking, rooms, totalPrice, vat, defaultCurrency } =
|
||||||
booking: state.booking,
|
useEnterDetailsStore((state) => ({
|
||||||
rooms: state.rooms,
|
booking: state.booking,
|
||||||
totalPrice: state.totalPrice,
|
rooms: state.rooms,
|
||||||
vat: state.vat,
|
totalPrice: state.totalPrice,
|
||||||
}))
|
vat: state.vat,
|
||||||
|
defaultCurrency: state.defaultCurrency,
|
||||||
|
}))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SidePanel variant="summary">
|
<SidePanel variant="summary">
|
||||||
@@ -29,6 +31,7 @@ export default function DesktopSummary({ isMember }: SummaryProps) {
|
|||||||
totalPrice={totalPrice}
|
totalPrice={totalPrice}
|
||||||
vat={vat}
|
vat={vat}
|
||||||
toggleSummaryOpen={toggleSummaryOpen}
|
toggleSummaryOpen={toggleSummaryOpen}
|
||||||
|
defaultCurrency={defaultCurrency}
|
||||||
/>
|
/>
|
||||||
</SidePanel>
|
</SidePanel>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -19,12 +19,14 @@ export default function MobileSummary({ isMember }: SummaryProps) {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
const { booking, rooms, totalPrice, vat } = useEnterDetailsStore((state) => ({
|
const { booking, rooms, totalPrice, vat, defaultCurrency } =
|
||||||
booking: state.booking,
|
useEnterDetailsStore((state) => ({
|
||||||
rooms: state.rooms,
|
booking: state.booking,
|
||||||
totalPrice: state.totalPrice,
|
rooms: state.rooms,
|
||||||
vat: state.vat,
|
totalPrice: state.totalPrice,
|
||||||
}))
|
vat: state.vat,
|
||||||
|
defaultCurrency: state.defaultCurrency,
|
||||||
|
}))
|
||||||
|
|
||||||
const showPromo =
|
const showPromo =
|
||||||
!isMember &&
|
!isMember &&
|
||||||
@@ -58,6 +60,7 @@ export default function MobileSummary({ isMember }: SummaryProps) {
|
|||||||
totalPrice={totalPrice}
|
totalPrice={totalPrice}
|
||||||
vat={vat}
|
vat={vat}
|
||||||
toggleSummaryOpen={toggleSummaryOpen}
|
toggleSummaryOpen={toggleSummaryOpen}
|
||||||
|
defaultCurrency={defaultCurrency}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</SummaryBottomSheet>
|
</SummaryBottomSheet>
|
||||||
|
|||||||
@@ -28,14 +28,6 @@ import styles from "./ui.module.css"
|
|||||||
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
||||||
import type { RoomRate } from "@/types/components/hotelReservation/enterDetails/details"
|
import type { RoomRate } from "@/types/components/hotelReservation/enterDetails/details"
|
||||||
import type { EnterDetailsSummaryProps } from "@/types/components/hotelReservation/summary"
|
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({
|
export default function SummaryUI({
|
||||||
booking,
|
booking,
|
||||||
@@ -44,6 +36,7 @@ export default function SummaryUI({
|
|||||||
isMember,
|
isMember,
|
||||||
vat,
|
vat,
|
||||||
toggleSummaryOpen,
|
toggleSummaryOpen,
|
||||||
|
defaultCurrency,
|
||||||
}: EnterDetailsSummaryProps) {
|
}: EnterDetailsSummaryProps) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const lang = useLang()
|
const lang = useLang()
|
||||||
@@ -190,10 +183,6 @@ export default function SummaryUI({
|
|||||||
|
|
||||||
const guests = guestsParts.join(", ")
|
const guests = guestsParts.join(", ")
|
||||||
|
|
||||||
const hideBedCurrency = notDisplayableCurrencies.includes(
|
|
||||||
room.roomPrice.perStay.local.currency
|
|
||||||
)
|
|
||||||
|
|
||||||
let rateDetails = room.rateDetails
|
let rateDetails = room.rateDetails
|
||||||
if (room.memberRateDetails) {
|
if (room.memberRateDetails) {
|
||||||
if (isMember || room.guest.join) {
|
if (isMember || room.guest.join) {
|
||||||
@@ -201,6 +190,8 @@ export default function SummaryUI({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const zeroPrice = formatPrice(intl, 0, defaultCurrency)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment key={idx}>
|
<Fragment key={idx}>
|
||||||
<div
|
<div
|
||||||
@@ -314,15 +305,7 @@ export default function SummaryUI({
|
|||||||
{room.bedType.description}
|
{room.bedType.description}
|
||||||
</Body>
|
</Body>
|
||||||
|
|
||||||
<Body color="uiTextHighContrast">
|
<Body color="uiTextHighContrast">{zeroPrice}</Body>
|
||||||
{formatPrice(
|
|
||||||
intl,
|
|
||||||
0,
|
|
||||||
hideBedCurrency
|
|
||||||
? ""
|
|
||||||
: room.roomPrice.perStay.local.currency
|
|
||||||
)}
|
|
||||||
</Body>
|
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{childBedCrib ? (
|
{childBedCrib ? (
|
||||||
@@ -342,13 +325,7 @@ export default function SummaryUI({
|
|||||||
})}
|
})}
|
||||||
</Caption>
|
</Caption>
|
||||||
</div>
|
</div>
|
||||||
<Body color="uiTextHighContrast">
|
<Body color="uiTextHighContrast">{zeroPrice}</Body>
|
||||||
{formatPrice(
|
|
||||||
intl,
|
|
||||||
0,
|
|
||||||
room.roomPrice.perStay.local.currency
|
|
||||||
)}
|
|
||||||
</Body>
|
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{childBedExtraBed ? (
|
{childBedExtraBed ? (
|
||||||
@@ -365,13 +342,7 @@ export default function SummaryUI({
|
|||||||
)}
|
)}
|
||||||
</Body>
|
</Body>
|
||||||
</div>
|
</div>
|
||||||
<Body color="uiTextHighContrast">
|
<Body color="uiTextHighContrast">{zeroPrice}</Body>
|
||||||
{formatPrice(
|
|
||||||
intl,
|
|
||||||
0,
|
|
||||||
room.roomPrice.perStay.local.currency
|
|
||||||
)}
|
|
||||||
</Body>
|
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
<Breakfast
|
<Breakfast
|
||||||
@@ -405,6 +376,7 @@ export default function SummaryUI({
|
|||||||
toDate={booking.toDate}
|
toDate={booking.toDate}
|
||||||
totalPrice={totalPrice}
|
totalPrice={totalPrice}
|
||||||
vat={vat}
|
vat={vat}
|
||||||
|
defaultCurrency={defaultCurrency}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export default function PriceDetails() {
|
|||||||
toDate={toDate}
|
toDate={toDate}
|
||||||
totalPrice={totalPrice}
|
totalPrice={totalPrice}
|
||||||
vat={bookedRoom.vatPercentage}
|
vat={bookedRoom.vatPercentage}
|
||||||
|
defaultCurrency={bookedRoom.currencyCode}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import type { BreakfastPackage } from "@/types/components/hotelReservation/break
|
|||||||
import type { BedTypeSchema } from "@/types/components/hotelReservation/enterDetails/bedType"
|
import type { BedTypeSchema } from "@/types/components/hotelReservation/enterDetails/bedType"
|
||||||
import type { Price } from "@/types/components/hotelReservation/price"
|
import type { Price } from "@/types/components/hotelReservation/price"
|
||||||
import type { Child } from "@/types/components/hotelReservation/selectRate/selectRate"
|
import type { Child } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||||
|
import type { CurrencyEnum } from "@/types/enums/currency"
|
||||||
import type { Package, Packages } from "@/types/requests/packages"
|
import type { Package, Packages } from "@/types/requests/packages"
|
||||||
|
|
||||||
type RoomPrice =
|
type RoomPrice =
|
||||||
@@ -59,6 +60,7 @@ export interface PriceDetailsTableProps {
|
|||||||
toDate: string
|
toDate: string
|
||||||
totalPrice: Price
|
totalPrice: Price
|
||||||
vat: number
|
vat: number
|
||||||
|
defaultCurrency: CurrencyEnum
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function PriceDetailsTable({
|
export default function PriceDetailsTable({
|
||||||
@@ -69,6 +71,7 @@ export default function PriceDetailsTable({
|
|||||||
toDate,
|
toDate,
|
||||||
totalPrice,
|
totalPrice,
|
||||||
vat,
|
vat,
|
||||||
|
defaultCurrency,
|
||||||
}: PriceDetailsTableProps) {
|
}: PriceDetailsTableProps) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const lang = useLang()
|
const lang = useLang()
|
||||||
@@ -122,11 +125,7 @@ export default function PriceDetailsTable({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!currency) {
|
if (!currency) {
|
||||||
if (room.packages?.length) {
|
currency = defaultCurrency
|
||||||
currency = room.packages[0].localPrice.currency
|
|
||||||
} else if (room.breakfast) {
|
|
||||||
currency = room.breakfast.localPrice.currency
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!price && !voucherPrice && !chequePrice && !redemptionPrice) {
|
if (!price && !voucherPrice && !chequePrice && !redemptionPrice) {
|
||||||
|
|||||||
@@ -36,7 +36,10 @@ export default function Summary({
|
|||||||
vat,
|
vat,
|
||||||
toggleSummaryOpen,
|
toggleSummaryOpen,
|
||||||
}: SelectRateSummaryProps) {
|
}: SelectRateSummaryProps) {
|
||||||
const rateSummary = useRatesStore((state) => state.rateSummary)
|
const { rateSummary, defaultCurrency } = useRatesStore((state) => ({
|
||||||
|
rateSummary: state.rateSummary,
|
||||||
|
defaultCurrency: state.defaultCurrency,
|
||||||
|
}))
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const lang = useLang()
|
const lang = useLang()
|
||||||
|
|
||||||
@@ -153,6 +156,7 @@ export default function Summary({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const roomPackages = room.packages
|
const roomPackages = room.packages
|
||||||
|
const zeroPrice = formatPrice(intl, 0, defaultCurrency)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment key={idx}>
|
<Fragment key={idx}>
|
||||||
@@ -247,13 +251,7 @@ export default function Summary({
|
|||||||
})}
|
})}
|
||||||
</Caption>
|
</Caption>
|
||||||
</div>
|
</div>
|
||||||
<Body color="uiTextHighContrast">
|
<Body color="uiTextHighContrast">{zeroPrice}</Body>
|
||||||
{formatPrice(
|
|
||||||
intl,
|
|
||||||
0,
|
|
||||||
room.roomPrice.perStay.local.currency
|
|
||||||
)}
|
|
||||||
</Body>
|
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{childBedExtraBed ? (
|
{childBedExtraBed ? (
|
||||||
@@ -270,13 +268,7 @@ export default function Summary({
|
|||||||
)}
|
)}
|
||||||
</Body>
|
</Body>
|
||||||
</div>
|
</div>
|
||||||
<Body color="uiTextHighContrast">
|
<Body color="uiTextHighContrast">{zeroPrice}</Body>
|
||||||
{formatPrice(
|
|
||||||
intl,
|
|
||||||
0,
|
|
||||||
room.roomPrice.perStay.local.currency
|
|
||||||
)}
|
|
||||||
</Body>
|
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{roomPackages?.map((pkg) => (
|
{roomPackages?.map((pkg) => (
|
||||||
@@ -317,6 +309,7 @@ export default function Summary({
|
|||||||
toDate={booking.toDate}
|
toDate={booking.toDate}
|
||||||
totalPrice={totalPrice}
|
totalPrice={totalPrice}
|
||||||
vat={vat}
|
vat={vat}
|
||||||
|
defaultCurrency={defaultCurrency}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -378,6 +378,7 @@ export function createDetailsStore(
|
|||||||
searchParamString: searchParams,
|
searchParamString: searchParams,
|
||||||
totalPrice: initialTotalPrice,
|
totalPrice: initialTotalPrice,
|
||||||
vat: initialState.vat,
|
vat: initialState.vat,
|
||||||
|
defaultCurrency: breakfastPackages[0].localPrice.currency,
|
||||||
preSubmitCallbacks: {},
|
preSubmitCallbacks: {},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
||||||
|
import { CurrencyEnum } from "@/types/enums/currency"
|
||||||
import type { AvailabilityError } from "@/types/stores/rates"
|
import type { AvailabilityError } from "@/types/stores/rates"
|
||||||
import type {
|
import type {
|
||||||
Product,
|
Product,
|
||||||
RoomConfiguration,
|
RoomConfiguration,
|
||||||
|
RoomsAvailability,
|
||||||
} from "@/types/trpc/routers/hotel/roomAvailability"
|
} from "@/types/trpc/routers/hotel/roomAvailability"
|
||||||
|
|
||||||
export function findProduct(
|
export function findProduct(
|
||||||
@@ -117,3 +119,28 @@ export function clearRoomSelectionFromUrl(
|
|||||||
searchParams.delete(`room[${roomIdx}].roomtype`)
|
searchParams.delete(`room[${roomIdx}].roomtype`)
|
||||||
return searchParams
|
return searchParams
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function findDefaultCurrency(
|
||||||
|
roomsAvailability: (RoomsAvailability | AvailabilityError)[] | undefined
|
||||||
|
) {
|
||||||
|
if (!roomsAvailability || !roomsAvailability.length) {
|
||||||
|
return CurrencyEnum.Unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
const availability = roomsAvailability.filter(
|
||||||
|
(room): room is RoomsAvailability => {
|
||||||
|
if ("error" in room) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
)[0]
|
||||||
|
|
||||||
|
const pkg = availability?.packages.find((pkg) => pkg.localPrice.currency)
|
||||||
|
if (!pkg) {
|
||||||
|
return CurrencyEnum.Unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultCurrency = pkg.localPrice.currency
|
||||||
|
return defaultCurrency
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { RatesContext } from "@/contexts/Rates"
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
clearRoomSelectionFromUrl,
|
clearRoomSelectionFromUrl,
|
||||||
|
findDefaultCurrency,
|
||||||
findProductInRoom,
|
findProductInRoom,
|
||||||
findSelectedRate,
|
findSelectedRate,
|
||||||
} from "./helpers"
|
} from "./helpers"
|
||||||
@@ -118,6 +119,8 @@ export function createRatesStore({
|
|||||||
|
|
||||||
const isRedemptionBooking = booking.searchType === REDEMPTION
|
const isRedemptionBooking = booking.searchType === REDEMPTION
|
||||||
|
|
||||||
|
const defaultCurrency = findDefaultCurrency(roomsAvailability)
|
||||||
|
|
||||||
return create<RatesState>()((set) => {
|
return create<RatesState>()((set) => {
|
||||||
return {
|
return {
|
||||||
activeRoom,
|
activeRoom,
|
||||||
@@ -133,6 +136,7 @@ export function createRatesStore({
|
|||||||
roomsAvailability,
|
roomsAvailability,
|
||||||
searchParams,
|
searchParams,
|
||||||
vat,
|
vat,
|
||||||
|
defaultCurrency,
|
||||||
rooms: booking.rooms.map((room, idx) => {
|
rooms: booking.rooms.map((room, idx) => {
|
||||||
const roomConfiguration = roomConfigurations[idx]
|
const roomConfiguration = roomConfigurations[idx]
|
||||||
const roomPackages = roomsPackages[idx]
|
const roomPackages = roomsPackages[idx]
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import type { CurrencyEnum } from "@/types/enums/currency"
|
||||||
import type { Packages } from "@/types/requests/packages"
|
import type { Packages } from "@/types/requests/packages"
|
||||||
import type { RoomState } from "@/types/stores/enter-details"
|
import type { RoomState } from "@/types/stores/enter-details"
|
||||||
import type { RoomPrice, RoomRate } from "./enterDetails/details"
|
import type { RoomPrice, RoomRate } from "./enterDetails/details"
|
||||||
@@ -25,6 +26,7 @@ export interface EnterDetailsSummaryProps {
|
|||||||
vat: number
|
vat: number
|
||||||
rooms: RoomState[]
|
rooms: RoomState[]
|
||||||
toggleSummaryOpen: () => void
|
toggleSummaryOpen: () => void
|
||||||
|
defaultCurrency: CurrencyEnum
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SelectRateSummaryProps {
|
export interface SelectRateSummaryProps {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import type {
|
|||||||
RoomRate,
|
RoomRate,
|
||||||
SignedInDetailsSchema,
|
SignedInDetailsSchema,
|
||||||
} from "@/types/components/hotelReservation/enterDetails/details"
|
} from "@/types/components/hotelReservation/enterDetails/details"
|
||||||
|
import type { CurrencyEnum } from "@/types/enums/currency"
|
||||||
import type { StepEnum } from "@/types/enums/step"
|
import type { StepEnum } from "@/types/enums/step"
|
||||||
import type { Price } from "../components/hotelReservation/price"
|
import type { Price } from "../components/hotelReservation/price"
|
||||||
import type {
|
import type {
|
||||||
@@ -102,6 +103,7 @@ export interface DetailsState {
|
|||||||
searchParamString: string
|
searchParamString: string
|
||||||
totalPrice: Price
|
totalPrice: Price
|
||||||
vat: number
|
vat: number
|
||||||
|
defaultCurrency: CurrencyEnum
|
||||||
preSubmitCallbacks: Record<string, () => void>
|
preSubmitCallbacks: Record<string, () => void>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type {
|
|||||||
Room as RoomBooking,
|
Room as RoomBooking,
|
||||||
SelectRateSearchParams,
|
SelectRateSearchParams,
|
||||||
} from "@/types/components/hotelReservation/selectRate/selectRate"
|
} from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||||
|
import type { CurrencyEnum } from "@/types/enums/currency"
|
||||||
import type { Room } from "@/types/hotel"
|
import type { Room } from "@/types/hotel"
|
||||||
import type { Package, PackageEnum } from "@/types/requests/packages"
|
import type { Package, PackageEnum } from "@/types/requests/packages"
|
||||||
import type {
|
import type {
|
||||||
@@ -66,6 +67,7 @@ export interface RatesState {
|
|||||||
roomsAvailability: (RoomsAvailability | AvailabilityError)[] | undefined
|
roomsAvailability: (RoomsAvailability | AvailabilityError)[] | undefined
|
||||||
searchParams: URLSearchParams
|
searchParams: URLSearchParams
|
||||||
vat: number
|
vat: number
|
||||||
|
defaultCurrency: CurrencyEnum
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface InitialState
|
export interface InitialState
|
||||||
|
|||||||
Reference in New Issue
Block a user