fix: change euro price to user's currency + merge state correctly
This commit is contained in:
@@ -77,9 +77,9 @@ export function subtract(...nums: (number | string | undefined)[]) {
|
||||
export function getInitialRoomPrice(roomRate: RoomRate, isMember: boolean) {
|
||||
if (isMember && roomRate.memberRate) {
|
||||
return {
|
||||
euro: {
|
||||
currency: CurrencyEnum.EUR,
|
||||
price: roomRate.memberRate.requestedPrice?.pricePerStay ?? 0,
|
||||
requested: roomRate.memberRate.requestedPrice && {
|
||||
currency: roomRate.memberRate.requestedPrice.currency,
|
||||
price: roomRate.memberRate.requestedPrice.pricePerStay,
|
||||
},
|
||||
local: {
|
||||
currency: roomRate.memberRate.localPrice.currency,
|
||||
@@ -89,9 +89,9 @@ export function getInitialRoomPrice(roomRate: RoomRate, isMember: boolean) {
|
||||
}
|
||||
|
||||
return {
|
||||
euro: {
|
||||
currency: CurrencyEnum.EUR,
|
||||
price: roomRate.publicRate.requestedPrice?.pricePerStay ?? 0,
|
||||
requested: roomRate.publicRate.requestedPrice && {
|
||||
currency: roomRate.publicRate.requestedPrice.currency,
|
||||
price: roomRate.publicRate.requestedPrice.pricePerStay,
|
||||
},
|
||||
local: {
|
||||
currency: roomRate.publicRate.localPrice.currency,
|
||||
@@ -103,9 +103,9 @@ export function getInitialRoomPrice(roomRate: RoomRate, isMember: boolean) {
|
||||
export function getInitialTotalPrice(roomRate: RoomRate, isMember: boolean) {
|
||||
if (isMember && roomRate.memberRate) {
|
||||
return {
|
||||
euro: {
|
||||
currency: CurrencyEnum.EUR,
|
||||
price: roomRate.memberRate.requestedPrice?.pricePerStay ?? 0,
|
||||
requested: roomRate.memberRate.requestedPrice && {
|
||||
currency: roomRate.memberRate.requestedPrice.currency,
|
||||
price: roomRate.memberRate.requestedPrice.pricePerStay,
|
||||
},
|
||||
local: {
|
||||
currency: roomRate.memberRate.localPrice.currency,
|
||||
@@ -115,9 +115,9 @@ export function getInitialTotalPrice(roomRate: RoomRate, isMember: boolean) {
|
||||
}
|
||||
|
||||
return {
|
||||
euro: {
|
||||
currency: CurrencyEnum.EUR,
|
||||
price: roomRate.publicRate.requestedPrice?.pricePerStay ?? 0,
|
||||
requested: roomRate.publicRate.requestedPrice && {
|
||||
currency: roomRate.publicRate.requestedPrice.currency,
|
||||
price: roomRate.publicRate.requestedPrice.pricePerStay,
|
||||
},
|
||||
local: {
|
||||
currency: roomRate.publicRate.localPrice.currency,
|
||||
@@ -165,31 +165,31 @@ export function calcTotalPrice(
|
||||
totalPrice: state.totalPrice,
|
||||
}
|
||||
if (state.requestedPrice?.pricePerStay) {
|
||||
roomAndTotalPrice.roomPrice.euro = {
|
||||
currency: CurrencyEnum.EUR,
|
||||
roomAndTotalPrice.roomPrice.requested = {
|
||||
currency: state.requestedPrice.currency,
|
||||
price: state.requestedPrice.pricePerStay,
|
||||
}
|
||||
|
||||
let totalPriceEuro = state.requestedPrice.pricePerStay
|
||||
let totalPriceRequested = state.requestedPrice.pricePerStay
|
||||
if (state.breakfast) {
|
||||
totalPriceEuro = add(
|
||||
totalPriceEuro,
|
||||
totalPriceRequested = add(
|
||||
totalPriceRequested,
|
||||
state.breakfast.requestedPrice.totalPrice
|
||||
)
|
||||
}
|
||||
|
||||
if (state.packages) {
|
||||
totalPriceEuro = state.packages.reduce((total, pkg) => {
|
||||
totalPriceRequested = state.packages.reduce((total, pkg) => {
|
||||
if (pkg.requestedPrice.totalPrice) {
|
||||
total = add(total, pkg.requestedPrice.totalPrice)
|
||||
}
|
||||
return total
|
||||
}, totalPriceEuro)
|
||||
}, totalPriceRequested)
|
||||
}
|
||||
|
||||
roomAndTotalPrice.totalPrice.euro = {
|
||||
currency: CurrencyEnum.EUR,
|
||||
price: totalPriceEuro,
|
||||
roomAndTotalPrice.totalPrice.requested = {
|
||||
currency: state.requestedPrice.currency,
|
||||
price: totalPriceRequested,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user