feat: SW-2028 Fixed review comments
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { create } from "zustand"
|
||||
|
||||
import { CurrencyEnum } from "@/types/enums/currency"
|
||||
|
||||
interface RoomPrice {
|
||||
id: string
|
||||
totalPrice: number
|
||||
currencyCode: string
|
||||
currencyCode: CurrencyEnum
|
||||
isMainBooking?: boolean
|
||||
roomPoints: number
|
||||
}
|
||||
@@ -11,7 +13,7 @@ interface RoomPrice {
|
||||
interface MyStayTotalPriceState {
|
||||
rooms: RoomPrice[]
|
||||
totalPrice: number | null
|
||||
currencyCode: string
|
||||
currencyCode: CurrencyEnum
|
||||
totalPoints: number
|
||||
actions: {
|
||||
// Add a single room price
|
||||
@@ -26,7 +28,7 @@ export const useMyStayTotalPriceStore = create<MyStayTotalPriceState>(
|
||||
totalPoints: 0,
|
||||
totalCheques: 0,
|
||||
totalVouchers: 0,
|
||||
currencyCode: "",
|
||||
currencyCode: CurrencyEnum.Unknown,
|
||||
actions: {
|
||||
addRoomPrice: (room) => {
|
||||
set((state) => {
|
||||
@@ -44,7 +46,7 @@ export const useMyStayTotalPriceStore = create<MyStayTotalPriceState>(
|
||||
|
||||
// Get currency from main booking or first room
|
||||
const mainRoom = newRooms.find((r) => r.isMainBooking) || newRooms[0]
|
||||
const currencyCode = mainRoom?.currencyCode || ""
|
||||
const currencyCode = mainRoom?.currencyCode ?? CurrencyEnum.Unknown
|
||||
|
||||
// Calculate total (only same currency for now)
|
||||
const total = newRooms.reduce((sum, r) => {
|
||||
|
||||
Reference in New Issue
Block a user