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:
@@ -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
|
||||
},
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user