Feat(SW-1279) mystay multirum cancelling * feat(SW-1279) Cancelation text if non-user on room 2-4 * feat(SW-1279) cancel mystay multiroom * feat(SW-1279): Added cancellation for multiroom on mystay Approved-by: Niclas Edenvin
59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
import { create } from "zustand"
|
|
|
|
interface RoomDetails {
|
|
id: string
|
|
roomName: string
|
|
roomTypeCode: string
|
|
rateDefinition: {
|
|
breakfastIncluded: boolean
|
|
cancellationRule: string | null
|
|
cancellationText: string | null
|
|
generalTerms: string[]
|
|
isMemberRate: boolean
|
|
mustBeGuaranteed: boolean
|
|
rateCode: string | null
|
|
title: string | null
|
|
}
|
|
isMainBooking?: boolean
|
|
}
|
|
|
|
interface MyStayRoomDetailsState {
|
|
rooms: RoomDetails[]
|
|
|
|
// Add a single room's details
|
|
addRoomDetails: (room: RoomDetails) => void
|
|
|
|
// Get room details by confirmationNumber
|
|
getRoomDetails: (confirmationNumber: string) => RoomDetails | undefined
|
|
}
|
|
|
|
export const useMyStayRoomDetailsStore = create<MyStayRoomDetailsState>(
|
|
(set, get) => ({
|
|
rooms: [],
|
|
|
|
addRoomDetails: (room) => {
|
|
set((state) => {
|
|
// Check if room with this ID already exists
|
|
const existingIndex = state.rooms.findIndex((r) => r.id === room.id)
|
|
let newRooms = [...state.rooms]
|
|
|
|
if (existingIndex >= 0) {
|
|
// Update existing room
|
|
newRooms[existingIndex] = room
|
|
} else {
|
|
// Add new room
|
|
newRooms.push(room)
|
|
}
|
|
|
|
return {
|
|
rooms: newRooms,
|
|
}
|
|
})
|
|
},
|
|
|
|
getRoomDetails: (confirmationNumber) => {
|
|
return get().rooms.find((room) => room.id === confirmationNumber)
|
|
},
|
|
})
|
|
)
|