Merged in feat(SW-2083)-missing-booking-codes-scenarios-my-stay (pull request #1680)

Feat(SW-2083) missing booking codes scenarios my stay

* feat(SW-2083) Show points instead of reward nights

* feat(SW-2083) added support for cheque and voucher for totalPrice


Approved-by: Niclas Edenvin
This commit is contained in:
Pontus Dreij
2025-03-31 11:42:47 +00:00
parent 7434f30c20
commit b48053b8b4
23 changed files with 240 additions and 33 deletions

View File

@@ -3,6 +3,7 @@ import { create } from "zustand"
import type { BreakfastPackage } from "@/types/components/hotelReservation/breakfast"
import type { BedTypeSchema } from "@/types/components/hotelReservation/enterDetails/bedType"
import type { RoomPrice } from "@/types/components/hotelReservation/enterDetails/details"
import type { PriceType } from "@/types/components/hotelReservation/myStay/myStay"
import type { Child } from "@/types/components/hotelReservation/selectRate/selectRate"
import type { Packages } from "@/types/requests/packages"
import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation"
@@ -21,6 +22,8 @@ export type Room = Pick<
| "confirmationNumber"
| "cancellationNumber"
| "bookingCode"
| "cheques"
| "vouchers"
| "isCancelable"
| "multiRoom"
| "canChangeDate"
@@ -28,6 +31,7 @@ export type Room = Pick<
| "roomTypeCode"
| "currencyCode"
| "vatPercentage"
| "roomPoints"
> & {
roomName: string
roomNumber: number | null
@@ -41,6 +45,7 @@ export type Room = Pick<
breakfast: BreakfastPackage | false
mainRoom: boolean
isPrePaid: boolean
priceType: PriceType
}
interface MyStayRoomDetailsState {
@@ -66,6 +71,8 @@ export const useMyStayRoomDetailsStore = create<MyStayRoomDetailsState>(
confirmationNumber: "",
cancellationNumber: null,
bookingCode: null,
cheques: 0,
vouchers: 0,
currencyCode: "",
guest: {
email: "",
@@ -85,6 +92,7 @@ export const useMyStayRoomDetailsStore = create<MyStayRoomDetailsState>(
rateCode: "",
title: null,
},
roomPoints: 0,
roomPrice: {
perNight: {
requested: {
@@ -129,6 +137,7 @@ export const useMyStayRoomDetailsStore = create<MyStayRoomDetailsState>(
linkedReservations: [],
isCancelable: false,
isPrePaid: false,
priceType: "money",
},
linkedReservationRooms: [],
actions: {

View File

@@ -5,25 +5,27 @@ interface RoomPrice {
totalPrice: number
currencyCode: string
isMainBooking?: boolean
roomPoints: number
}
interface MyStayTotalPriceState {
rooms: RoomPrice[]
totalPrice: number | null
currencyCode: string
totalPoints: number
actions: {
// Add a single room price
addRoomPrice: (room: RoomPrice) => void
// Get the calculated total
getTotalPrice: () => number | null
}
}
export const useMyStayTotalPriceStore = create<MyStayTotalPriceState>(
(set, get) => ({
(set) => ({
rooms: [],
totalPrice: null,
totalPoints: 0,
totalCheques: 0,
totalVouchers: 0,
currencyCode: "",
actions: {
addRoomPrice: (room) => {
@@ -52,17 +54,18 @@ export const useMyStayTotalPriceStore = create<MyStayTotalPriceState>(
return sum
}, 0)
const totalPoints = newRooms.reduce((sum, r) => {
return sum + r.roomPoints
}, 0)
return {
rooms: newRooms,
totalPrice: total,
currencyCode,
totalPoints,
}
})
},
getTotalPrice: () => {
return get().totalPrice
},
},
})
)