From 286d772de1baf7b4ac76450b36da471d82dd4dcd Mon Sep 17 00:00:00 2001 From: Fredrik Thorsson Date: Tue, 9 Jul 2024 16:36:37 +0200 Subject: [PATCH] feat: use getHotel data --- .../{layout.module.css => page.module.css} | 0 .../hotelreservation/select-hotel/page.tsx | 73 ++++--------------- .../SelectHotel/HotelCard/index.tsx | 21 +++--- constants/routes/hotelReservation.js | 14 +--- .../selectHotel/hotelCardProps.ts | 3 + types/hotel.ts | 1 + 6 files changed, 31 insertions(+), 81 deletions(-) rename app/[lang]/(live)/(public)/hotelreservation/select-hotel/{layout.module.css => page.module.css} (100%) create mode 100644 types/components/hotelReservation/selectHotel/hotelCardProps.ts diff --git a/app/[lang]/(live)/(public)/hotelreservation/select-hotel/layout.module.css b/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.module.css similarity index 100% rename from app/[lang]/(live)/(public)/hotelreservation/select-hotel/layout.module.css rename to app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.module.css diff --git a/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx index 7ba913844..91adda97c 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx @@ -1,67 +1,26 @@ +import { serverClient } from "@/lib/trpc/server" + import HotelCard from "@/components/HotelReservation/SelectHotel/HotelCard" -import { HotelCardData } from "@/components/HotelReservation/SelectHotel/HotelCard/data" -import styles from "./layout.module.css" +import styles from "./page.module.css" -export default function SelectHotelPage() { - const hotelData: HotelCardData[] = [ - { - hotel: { - name: "Helsinki Hub", - address: "Kaisaniemenkatu 7, Helsinki", - description: - "Modern urban hotel in a impressive 1920s printing house in Helsinki city centre.", - rooms: "Only 4 rooms left", - button: "Book from 1549 SEK/night", - label: [ - "Free cancellation until 18:00", - "Breakfast included", - "Free WiFi", - "Pay at the hotel", - ], - }, - }, - { - hotel: { - name: "Stockholm Serenity", - address: "Drottninggatan 99, Stockholm", - description: - "Charming boutique hotel located in the heart of Stockholm with scenic city views.", - rooms: "Only 2 rooms left", - button: "Book from 1899 SEK/night", - label: [ - "Free cancellation until 18:00", - "Breakfast included", - "Free WiFi", - "Fitness center", - "Pet friendly", - ], - }, - }, - { - hotel: { - name: "Copenhagen Comfort", - address: "Vesterbrogade 23, Copenhagen", - description: - "Elegant hotel offering modern amenities and quick access to Copenhagen's main attractions.", - rooms: "Only 3 rooms left", - button: "Book from 1725 SEK/night", - label: [ - "Free cancellation until 18:00", - "Breakfast included", - "Free WiFi", - "24-hour front desk", - "Airport shuttle", - ], - }, - }, - ] +import { LangParams, PageArgs } from "@/types/params" + +export default async function SelectHotelPage({ + params, +}: PageArgs) { + const hotel = await serverClient().hotel.getHotel({ + hotelId: "Stockholm", + language: params.lang, + }) + + const hotels = [hotel] return (
- {hotelData.map((data) => ( - + {hotels.map((hotel) => ( + ))}
diff --git a/components/HotelReservation/SelectHotel/HotelCard/index.tsx b/components/HotelReservation/SelectHotel/HotelCard/index.tsx index f96ab0bdd..360ea711d 100644 --- a/components/HotelReservation/SelectHotel/HotelCard/index.tsx +++ b/components/HotelReservation/SelectHotel/HotelCard/index.tsx @@ -4,12 +4,14 @@ import Button from "@/components/TempDesignSystem/Button" import Chip from "@/components/TempDesignSystem/Chip" import Body from "@/components/TempDesignSystem/Text/Body" import Title from "@/components/TempDesignSystem/Text/Title" - -import { HotelCardData } from "./data" +import { getIntl } from "@/i18n" import styles from "./hotelCard.module.css" -export default function HotelCard({ hotel }: HotelCardData) { +import { HotelCardProps } from "@/types/components/hotelReservation/selectHotel/hotelCardProps" + +export default async function HotelCard({ hotel }: HotelCardProps) { + const { formatMessage } = await getIntl() return (
hotel image @@ -19,12 +21,12 @@ export default function HotelCard({ hotel }: HotelCardData) { {hotel.name}
- {hotel.address} - {hotel.description} + {`${hotel.address.streetAddress}, ${hotel.address.city}`} + {hotel.hotelContent.texts.descriptions.short}
- {hotel.label.map((chip, index) => ( - {chip} + {hotel.detailedFacilities.slice(0, 6).map((chip, index) => ( + {chip.name} ))}
@@ -34,11 +36,8 @@ export default function HotelCard({ hotel }: HotelCardData) { size="small" className={styles.button} > - {hotel.button} + {formatMessage({ id: "Book" })} - - {hotel.rooms} -
diff --git a/constants/routes/hotelReservation.js b/constants/routes/hotelReservation.js index 547aca08f..ba0d6d4b6 100644 --- a/constants/routes/hotelReservation.js +++ b/constants/routes/hotelReservation.js @@ -8,16 +8,4 @@ export const hotelReservation = { de: "/de/hotelreservierung", } -export const selectHotel = { - en: `${hotelReservation.en}/select-hotel`, - sv: `${hotelReservation.sv}/välj-hotell`, - no: `${hotelReservation.no}/velg-hotell`, - fi: `${hotelReservation.fi}/valitse-hotelli`, - da: `${hotelReservation.da}/vælg-hotel`, - de: `${hotelReservation.de}/wähle-hotel`, -} - -export const bookingFlow = [ - ...Object.values(hotelReservation), - ...Object.values(selectHotel), -] +export const bookingFlow = [...Object.values(hotelReservation)] diff --git a/types/components/hotelReservation/selectHotel/hotelCardProps.ts b/types/components/hotelReservation/selectHotel/hotelCardProps.ts new file mode 100644 index 000000000..0099aa2df --- /dev/null +++ b/types/components/hotelReservation/selectHotel/hotelCardProps.ts @@ -0,0 +1,3 @@ +import { Hotel } from "@/types/hotel" + +export type HotelCardProps = { hotel: Hotel } diff --git a/types/hotel.ts b/types/hotel.ts index da72002ac..a8a715c3d 100644 --- a/types/hotel.ts +++ b/types/hotel.ts @@ -4,6 +4,7 @@ import { getHotelDataSchema } from "@/server/routers/hotels/output" export type HotelData = z.infer +export type Hotel = HotelData["data"]["attributes"] export type HotelAddress = HotelData["data"]["attributes"]["address"] export type HotelLocation = HotelData["data"]["attributes"]["location"] export type HotelTripAdvisor =