From 2750a4f4038ba096bb98cfdf7182d538e91b27a5 Mon Sep 17 00:00:00 2001 From: Pontus Dreij Date: Fri, 15 Nov 2024 20:18:57 +0100 Subject: [PATCH] fix(SW-881) fixing data issues --- .../SelectRate/RoomSelection/RateSummary/index.tsx | 2 +- .../SelectRate/RoomSelection/RoomCard/index.tsx | 2 +- .../HotelReservation/SelectRate/RoomSelection/index.tsx | 3 +-- server/routers/hotels/output.ts | 4 ++-- .../components/hotelReservation/selectRate/rateSummary.ts | 2 +- types/components/hotelReservation/selectRate/roomCard.ts | 2 +- .../components/hotelReservation/selectRate/roomFilter.ts | 8 +++----- .../hotelReservation/selectRate/roomSelection.ts | 2 +- 8 files changed, 11 insertions(+), 14 deletions(-) diff --git a/components/HotelReservation/SelectRate/RoomSelection/RateSummary/index.tsx b/components/HotelReservation/SelectRate/RoomSelection/RateSummary/index.tsx index 33400efaf..7700b1d29 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/RateSummary/index.tsx +++ b/components/HotelReservation/SelectRate/RoomSelection/RateSummary/index.tsx @@ -41,7 +41,7 @@ export default function RateSummary({ (feature) => feature.code === RoomPackageCodeEnum.PET_ROOM ) - const petRoomPackage = packages.find( + const petRoomPackage = packages?.find( (pkg) => pkg.code === RoomPackageCodeEnum.PET_ROOM ) diff --git a/components/HotelReservation/SelectRate/RoomSelection/RoomCard/index.tsx b/components/HotelReservation/SelectRate/RoomSelection/RoomCard/index.tsx index 47533dcdc..fb713fddb 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/RoomCard/index.tsx +++ b/components/HotelReservation/SelectRate/RoomSelection/RoomCard/index.tsx @@ -61,7 +61,7 @@ export default function RoomCard({ const petRoomPackage = (selectedPackages.includes(RoomPackageCodeEnum.PET_ROOM) && - packages.find((pkg) => pkg.code === RoomPackageCodeEnum.PET_ROOM)) || + packages?.find((pkg) => pkg.code === RoomPackageCodeEnum.PET_ROOM)) || undefined const selectedRoom = roomCategories.find( diff --git a/components/HotelReservation/SelectRate/RoomSelection/index.tsx b/components/HotelReservation/SelectRate/RoomSelection/index.tsx index ceb86c5f3..b3624552f 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/index.tsx +++ b/components/HotelReservation/SelectRate/RoomSelection/index.tsx @@ -1,6 +1,6 @@ "use client" import { useRouter, useSearchParams } from "next/navigation" -import { useMemo, useState } from "react" +import { useMemo } from "react" import RateSummary from "./RateSummary" import RoomCard from "./RoomCard" @@ -9,7 +9,6 @@ import { getHotelReservationQueryParams } from "./utils" import styles from "./roomSelection.module.css" import type { RoomSelectionProps } from "@/types/components/hotelReservation/selectRate/roomSelection" -import type { Rate } from "@/types/components/hotelReservation/selectRate/selectRate" export default function RoomSelection({ roomsAvailability, diff --git a/server/routers/hotels/output.ts b/server/routers/hotels/output.ts index da202c7d3..9bc81225e 100644 --- a/server/routers/hotels/output.ts +++ b/server/routers/hotels/output.ts @@ -855,7 +855,7 @@ export const breakfastPackagesSchema = z export const packagesSchema = z.object({ code: z.nativeEnum(RoomPackageCodeEnum), - itemCode: z.string(), + itemCode: z.string().optional(), description: z.string(), localPrice: packagePriceSchema, requestedPrice: packagePriceSchema, @@ -873,7 +873,7 @@ export const getRoomPackagesSchema = z data: z.object({ attributes: z.object({ hotelId: z.number(), - packages: z.array(packagesSchema), + packages: z.array(packagesSchema).optional().default([]), }), relationships: z .object({ diff --git a/types/components/hotelReservation/selectRate/rateSummary.ts b/types/components/hotelReservation/selectRate/rateSummary.ts index f6c0f03b6..40c595508 100644 --- a/types/components/hotelReservation/selectRate/rateSummary.ts +++ b/types/components/hotelReservation/selectRate/rateSummary.ts @@ -5,6 +5,6 @@ import type { Rate } from "./selectRate" export interface RateSummaryProps { rateSummary: Rate isUserLoggedIn: boolean - packages: RoomPackageData + packages: RoomPackageData | undefined roomsAvailability: RoomsAvailability } diff --git a/types/components/hotelReservation/selectRate/roomCard.ts b/types/components/hotelReservation/selectRate/roomCard.ts index 0f76afb56..aa0d647be 100644 --- a/types/components/hotelReservation/selectRate/roomCard.ts +++ b/types/components/hotelReservation/selectRate/roomCard.ts @@ -18,7 +18,7 @@ export type RoomCardProps = { rateDefinitions: RateDefinition[] roomCategories: RoomData[] selectedPackages: RoomPackageCodes[] - packages: RoomPackageData + packages: RoomPackageData | undefined handleSelectRate: (rate: Rate) => void } diff --git a/types/components/hotelReservation/selectRate/roomFilter.ts b/types/components/hotelReservation/selectRate/roomFilter.ts index 78980be83..f895ed73a 100644 --- a/types/components/hotelReservation/selectRate/roomFilter.ts +++ b/types/components/hotelReservation/selectRate/roomFilter.ts @@ -16,9 +16,7 @@ export interface RoomFilterProps { filterOptions: RoomPackageData } -export interface RoomPackageData - extends z.output {} - -export type RoomPackageCodes = RoomPackageData[number]["code"] - export type RoomPackage = z.output +export interface RoomPackageData extends Array {} + +export type RoomPackageCodes = RoomPackage["code"] diff --git a/types/components/hotelReservation/selectRate/roomSelection.ts b/types/components/hotelReservation/selectRate/roomSelection.ts index 63b17ed6f..163bfd6fa 100644 --- a/types/components/hotelReservation/selectRate/roomSelection.ts +++ b/types/components/hotelReservation/selectRate/roomSelection.ts @@ -8,7 +8,7 @@ export interface RoomSelectionProps { roomsAvailability: RoomsAvailability roomCategories: RoomData[] user: SafeUser - packages: RoomPackageData + packages: RoomPackageData | undefined selectedPackages: RoomPackageCodes[] setRateSummary: (rateSummary: Rate) => void rateSummary: Rate | null