Merged in feat/SW-1437-price-change-scenario (pull request #1532)

Feat/SW-1437 price change scenario

* wip price change scenario

* feat(SW-1437): added updated room prices to summary

* fix: spinner not centered on page

* fix: feedback fixes


Approved-by: Arvid Norlin
Approved-by: Simon.Emanuelsson
This commit is contained in:
Tobias Johansson
2025-03-14 12:39:50 +00:00
parent abd401c4f4
commit c0b543f18d
16 changed files with 489 additions and 75 deletions

View File

@@ -56,5 +56,5 @@ export default function PaymentCallback({
}
}, [returnUrl, router, searchObject, status, errorMessage])
return <LoadingSpinner />
return <LoadingSpinner fullPage />
}

View File

@@ -51,7 +51,10 @@ import { type PaymentFormData, paymentSchema } from "./schema"
import styles from "./payment.module.css"
import type { PaymentClientProps } from "@/types/components/hotelReservation/enterDetails/payment"
import type {
PaymentClientProps,
PriceChangeData,
} from "@/types/components/hotelReservation/enterDetails/payment"
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
const maxRetries = 15
@@ -97,10 +100,8 @@ export default function PaymentClient({
const availablePaymentOptions =
useAvailablePaymentOptions(otherPaymentOptions)
const [priceChangeData, setPriceChangeData] = useState<{
oldPrice: number
newPrice: number
} | null>()
const [priceChangeData, setPriceChangeData] =
useState<PriceChangeData | null>(null)
const { toDate, fromDate, hotelId } = booking
@@ -143,15 +144,12 @@ export default function PaymentClient({
setBookingNumber(result.id)
const priceChange = result.rooms.find(
(r) => r.priceChangedMetadata
)?.priceChangedMetadata
if (priceChange) {
setPriceChangeData({
oldPrice: rooms[0].room.roomPrice.perStay.local.price,
newPrice: priceChange.totalPrice,
})
const hasPriceChange = result.rooms.some((r) => r.priceChangedMetadata)
if (hasPriceChange) {
const priceChangeData = result.rooms.map(
(room) => room.priceChangedMetadata || null
)
setPriceChangeData(priceChangeData)
} else {
setIsPollingForBookingStatus(true)
}
@@ -172,7 +170,6 @@ export default function PaymentClient({
} else {
handlePaymentError("No confirmation number")
}
setPriceChangeData(null)
},
onError: (error) => {
@@ -518,8 +515,8 @@ export default function PaymentClient({
{priceChangeData ? (
<PriceChangeDialog
isOpen={!!priceChangeData}
oldPrice={priceChangeData.oldPrice}
newPrice={priceChangeData.newPrice}
priceChangeData={priceChangeData}
prevTotalPrice={totalPrice.local.price}
currency={totalPrice.local.currency}
onCancel={() => {
const allSearchParams = searchParams.size

View File

@@ -14,8 +14,11 @@ export function hasPrepaidRate({ room }: RoomState): boolean {
return !room.isFlexRate
}
export function calculateTotalRoomPrice({ room }: RoomState) {
let totalPrice = room.roomPrice.perStay.local.price
export function calculateTotalRoomPrice(
{ room }: RoomState,
initialRoomPrice?: number
) {
let totalPrice = initialRoomPrice ?? room.roomPrice.perStay.local.price
if (room.breakfast) {
totalPrice += Number(room.breakfast.localPrice.totalPrice) * room.adults