Merged in feat/SW-2079-update-booking-page-to-show-points- (pull request #1683)
feat: SW-2079 Show points in confirmation page * feat: SW-2079 Show points in confirmation page * feat: SW-2079 Optimized code * feat: SW-2079 Updated Body to Typography * feat: SW-2079 Multi-room total cost display * feat: SW-2079 Add reward nights condition rate title * feat: SW-2079 Removed extra checks * feat: SW-2079 Optimmized formatPrice function * feat: SW-2079 Typo fix Approved-by: Christian Andolf
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
"use client"
|
||||
|
||||
import { useEffect } from "react"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { trpc } from "@/lib/trpc/client"
|
||||
import { useBookingConfirmationStore } from "@/stores/booking-confirmation"
|
||||
|
||||
import useLang from "@/hooks/useLang"
|
||||
import { formatPrice } from "@/utils/numberFormatting"
|
||||
|
||||
import { mapRoomState } from "../../utils"
|
||||
import Room from "../Room"
|
||||
@@ -25,14 +27,36 @@ export function LinkedReservation({
|
||||
confirmationNumber,
|
||||
lang,
|
||||
})
|
||||
const setRoom = useBookingConfirmationStore((state) => state.actions.setRoom)
|
||||
const { setRoom, setFormattedTotalCost, currencyCode, totalBookingPrice } =
|
||||
useBookingConfirmationStore((state) => ({
|
||||
setRoom: state.actions.setRoom,
|
||||
setFormattedTotalCost: state.actions.setFormattedTotalCost,
|
||||
currencyCode: state.currencyCode,
|
||||
totalBookingPrice: state.totalBookingPrice,
|
||||
}))
|
||||
const intl = useIntl()
|
||||
|
||||
useEffect(() => {
|
||||
if (data?.room) {
|
||||
const roomData = mapRoomState(data.booking, data.room)
|
||||
const roomData = mapRoomState(data.booking, data.room, intl)
|
||||
setRoom(roomData, roomIndex)
|
||||
|
||||
const formattedTotalCost = formatPrice(
|
||||
intl,
|
||||
totalBookingPrice,
|
||||
currencyCode
|
||||
)
|
||||
setFormattedTotalCost(formattedTotalCost)
|
||||
}
|
||||
}, [data, roomIndex, setRoom])
|
||||
}, [
|
||||
data,
|
||||
roomIndex,
|
||||
setRoom,
|
||||
intl,
|
||||
totalBookingPrice,
|
||||
currencyCode,
|
||||
setFormattedTotalCost,
|
||||
])
|
||||
|
||||
if (isLoading) {
|
||||
return <LinkedReservationCardSkeleton />
|
||||
|
||||
Reference in New Issue
Block a user