diff --git a/app/[lang]/(live)/(public)/hotelreservation/select-rate/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/select-rate/page.tsx index da2ded541..353ab430b 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/select-rate/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/select-rate/page.tsx @@ -1,86 +1,17 @@ +import { serverClient } from "@/lib/trpc/server" + import RoomCard from "@/components/HotelReservation/SelectRate/RoomCard" -import { Room } from "@/components/HotelReservation/SelectRate/RoomCard/roomCard" import Header from "@/components/Section/Header" import { getIntl } from "@/i18n" import styles from "./page.module.css" -const getRooms: () => Promise = () => { - return new Promise((resolve) => - resolve([ - { - id: 1, - name: "Cabin", - description: - "Stylish, peaceful and air-conditioned room. The rooms have small clerestory windows.", - size: "17 - 24 m² (1 - 2 persons)", - pricePerNight: 1348, - currency: "SEK", - imageSrc: - "https://www.scandichotels.se/imageVault/publishedmedia/xnmqnmz6mz0uhuat0917/scandic-helsinki-hub-room-standard-KR-7.jpg", - }, - { - id: 2, - name: "Standard", - description: - "Stylish, peaceful and air-conditioned room. The rooms have small clerestory windows.", - size: "19 - 30 m² (1 - 2 persons)", - pricePerNight: 1548, - currency: "SEK", - imageSrc: - "https://www.scandichotels.se/imageVault/publishedmedia/xnmqnmz6mz0uhuat0917/scandic-helsinki-hub-room-standard-KR-7.jpg", - }, - { - id: 3, - name: "Superior", - description: - "Stylish, peaceful and air-conditioned room. The rooms have small clerestory windows.", - size: "22 - 40 m² (1 - 3 persons)", - pricePerNight: 1744, - currency: "SEK", - imageSrc: - "https://www.scandichotels.se/imageVault/publishedmedia/xnmqnmz6mz0uhuat0917/scandic-helsinki-hub-room-standard-KR-7.jpg", - }, - { - id: 4, - name: "Superior Family", - description: - "Stylish, peaceful and air-conditioned room. The rooms have small clerestory windows.", - size: "29 - 49 m² (3 - 4 persons)", - pricePerNight: 2032, - currency: "SEK", - imageSrc: - "https://www.scandichotels.se/imageVault/publishedmedia/xnmqnmz6mz0uhuat0917/scandic-helsinki-hub-room-standard-KR-7.jpg", - }, - { - id: 5, - name: "Superior PLUS", - description: - "Stylish, peaceful and air-conditioned room. The rooms have small clerestory windows.", - size: "21 - 28 m² (2 - 3 persons)", - pricePerNight: 2065, - currency: "SEK", - imageSrc: - "https://www.scandichotels.se/imageVault/publishedmedia/xnmqnmz6mz0uhuat0917/scandic-helsinki-hub-room-standard-KR-7.jpg", - }, - { - id: 6, - name: "Junior Suite", - description: - "Stylish, peaceful and air-conditioned room. The rooms have small clerestory windows.", - size: "35 - 43 m² (2 - 4 persons)", - pricePerNight: 3012, - currency: "SEK", - imageSrc: - "https://www.scandichotels.se/imageVault/publishedmedia/xnmqnmz6mz0uhuat0917/scandic-helsinki-hub-room-standard-KR-7.jpg", - }, - ]) - ) -} - export default async function SelectRate() { const { formatMessage } = await getIntl() - const rooms = await getRooms() + const rooms = await serverClient().hotel.getRates({ + // TODO: pass the correct hotel ID and all other parameters that should be included in the search + hotelId: "1", + }) return (
diff --git a/components/HotelReservation/SelectRate/RoomCard/roomCard.ts b/components/HotelReservation/SelectRate/RoomCard/roomCard.ts index c42f9304e..475a77396 100644 --- a/components/HotelReservation/SelectRate/RoomCard/roomCard.ts +++ b/components/HotelReservation/SelectRate/RoomCard/roomCard.ts @@ -1,11 +1,3 @@ -export type Room = { - id: number - name: string - description: string - size: string - pricePerNight: number - currency: string - imageSrc: string -} +import { Rate } from "@/server/routers/hotels/output" -export type RoomProps = { room: Room } +export type RoomProps = { room: Rate } diff --git a/server/routers/hotels/input.ts b/server/routers/hotels/input.ts index 2158c6b7a..bb8a1ebdd 100644 --- a/server/routers/hotels/input.ts +++ b/server/routers/hotels/input.ts @@ -6,3 +6,7 @@ export const getHotelInputSchema = z.object({ hotelId: z.string(), language: z.nativeEnum(Lang), }) + +export const getRatesInputSchema = z.object({ + hotelId: z.string(), +}) diff --git a/server/routers/hotels/output.ts b/server/routers/hotels/output.ts index dbeac7bc9..d62c25f5f 100644 --- a/server/routers/hotels/output.ts +++ b/server/routers/hotels/output.ts @@ -391,3 +391,17 @@ export const getHotelDataSchema = z.object({ // - Example "included" data available in our tempHotelData file. // included: z.any(), }) + +const Rate = z.object({ + id: z.number(), + name: z.string(), + description: z.string(), + size: z.string(), + pricePerNight: z.number(), + currency: z.string(), + imageSrc: z.string(), +}) + +export const getRatesSchema = z.array(Rate) + +export type Rate = z.infer diff --git a/server/routers/hotels/query.ts b/server/routers/hotels/query.ts index d9e026077..fb4ca8da3 100644 --- a/server/routers/hotels/query.ts +++ b/server/routers/hotels/query.ts @@ -2,9 +2,10 @@ import * as api from "@/lib/api" import { badRequestError } from "@/server/errors/trpc" import { publicProcedure, router } from "@/server/trpc" -import { getHotelInputSchema } from "./input" -import { getHotelDataSchema } from "./output" +import { getHotelInputSchema, getRatesInputSchema } from "./input" +import { getHotelDataSchema, getRatesSchema } from "./output" import tempHotelData from "./tempHotelData.json" +import tempRatesData from "./tempRatesData.json" import { toApiLang } from "./utils" export const hotelQueryRouter = router({ @@ -49,4 +50,25 @@ export const hotelQueryRouter = router({ return validatedHotelData.data.data.attributes }), + getRates: publicProcedure + .input(getRatesInputSchema) + .query(async ({ input, ctx }) => { + // TODO: Do a real API call when the endpoint is ready + // const { hotelId } = input + + // const params = new URLSearchParams() + // const apiLang = toApiLang(language) + // params.set("hotelId", hotelId.toString()) + // params.set("language", apiLang) + + const validatedHotelData = getRatesSchema.safeParse(tempRatesData) + + if (!validatedHotelData.success) { + console.info(`Get Individual Rates Data - Verified Data Error`) + console.error(validatedHotelData.error) + throw badRequestError() + } + + return validatedHotelData.data + }), }) diff --git a/server/routers/hotels/tempRatesData.json b/server/routers/hotels/tempRatesData.json new file mode 100644 index 000000000..4bd00d0be --- /dev/null +++ b/server/routers/hotels/tempRatesData.json @@ -0,0 +1,56 @@ +[ + { + "id": 1, + "name": "Cabin", + "description": "Stylish, peaceful and air-conditioned room. The rooms have small clerestory windows.", + "size": "17 - 24 m² (1 - 2 persons)", + "pricePerNight": 1348, + "currency": "SEK", + "imageSrc": "https://www.scandichotels.se/imageVault/publishedmedia/xnmqnmz6mz0uhuat0917/scandic-helsinki-hub-room-standard-KR-7.jpg" + }, + { + "id": 2, + "name": "Standard", + "description": "Stylish, peaceful and air-conditioned room. The rooms have small clerestory windows.", + "size": "19 - 30 m² (1 - 2 persons)", + "pricePerNight": 1548, + "currency": "SEK", + "imageSrc": "https://www.scandichotels.se/imageVault/publishedmedia/xnmqnmz6mz0uhuat0917/scandic-helsinki-hub-room-standard-KR-7.jpg" + }, + { + "id": 3, + "name": "Superior", + "description": "Stylish, peaceful and air-conditioned room. The rooms have small clerestory windows.", + "size": "22 - 40 m² (1 - 3 persons)", + "pricePerNight": 1744, + "currency": "SEK", + "imageSrc": "https://www.scandichotels.se/imageVault/publishedmedia/xnmqnmz6mz0uhuat0917/scandic-helsinki-hub-room-standard-KR-7.jpg" + }, + { + "id": 4, + "name": "Superior Family", + "description": "Stylish, peaceful and air-conditioned room. The rooms have small clerestory windows.", + "size": "29 - 49 m² (3 - 4 persons)", + "pricePerNight": 2032, + "currency": "SEK", + "imageSrc": "https://www.scandichotels.se/imageVault/publishedmedia/xnmqnmz6mz0uhuat0917/scandic-helsinki-hub-room-standard-KR-7.jpg" + }, + { + "id": 5, + "name": "Superior PLUS", + "description": "Stylish, peaceful and air-conditioned room. The rooms have small clerestory windows.", + "size": "21 - 28 m² (2 - 3 persons)", + "pricePerNight": 2065, + "currency": "SEK", + "imageSrc": "https://www.scandichotels.se/imageVault/publishedmedia/xnmqnmz6mz0uhuat0917/scandic-helsinki-hub-room-standard-KR-7.jpg" + }, + { + "id": 6, + "name": "Junior Suite", + "description": "Stylish, peaceful and air-conditioned room. The rooms have small clerestory windows.", + "size": "35 - 43 m² (2 - 4 persons)", + "pricePerNight": 3012, + "currency": "SEK", + "imageSrc": "https://www.scandichotels.se/imageVault/publishedmedia/xnmqnmz6mz0uhuat0917/scandic-helsinki-hub-room-standard-KR-7.jpg" + } +]