From aff27f64a7d15ad76042bac58abcec1c0f4b0a83 Mon Sep 17 00:00:00 2001 From: Chuma McPhoy Date: Mon, 8 Jul 2024 12:36:38 +0200 Subject: [PATCH] chore: create a IntroSectionProps type --- components/ContentType/HotelPage/HotelPage.tsx | 13 +++++++------ .../ContentType/HotelPage/IntroSection/index.tsx | 12 +++--------- .../ContentType/HotelPage/IntroSection/types.ts | 14 ++++++++++++++ types/hotel.ts | 2 ++ 4 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 components/ContentType/HotelPage/IntroSection/types.ts diff --git a/components/ContentType/HotelPage/HotelPage.tsx b/components/ContentType/HotelPage/HotelPage.tsx index 9ced92da2..fd33b63b8 100644 --- a/components/ContentType/HotelPage/HotelPage.tsx +++ b/components/ContentType/HotelPage/HotelPage.tsx @@ -19,21 +19,22 @@ export default async function HotelPage({ lang }: LangParams) { hotelId: hotelPageIdentifierData.hotel_page_id, language: lang, }) + const hotelAttributes = hotelPageData.data.attributes return (
diff --git a/components/ContentType/HotelPage/IntroSection/index.tsx b/components/ContentType/HotelPage/IntroSection/index.tsx index 0627b31f1..9144a53f6 100644 --- a/components/ContentType/HotelPage/IntroSection/index.tsx +++ b/components/ContentType/HotelPage/IntroSection/index.tsx @@ -7,9 +7,9 @@ import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" import Title from "@/components/TempDesignSystem/Text/Title" import { getIntl } from "@/i18n" -import styles from "./introSection.module.css" +import { IntroSectionProps } from "./types" -import { HotelAddress, HotelData, HotelLocation } from "@/types/hotel" +import styles from "./introSection.module.css" export default async function IntroSection({ hotelName, @@ -17,13 +17,7 @@ export default async function IntroSection({ location, address, tripAdvisor, -}: { - hotelName: HotelData["data"]["attributes"]["name"] - hotelDescription: HotelData["data"]["attributes"]["hotelContent"]["texts"]["descriptions"]["short"] - location: HotelLocation - address: HotelAddress - tripAdvisor: HotelData["data"]["attributes"]["ratings"]["tripAdvisor"] -}) { +}: IntroSectionProps) { const intl = await getIntl() const { formatMessage } = intl const { streetAddress, city } = address diff --git a/components/ContentType/HotelPage/IntroSection/types.ts b/components/ContentType/HotelPage/IntroSection/types.ts new file mode 100644 index 000000000..88c23f13b --- /dev/null +++ b/components/ContentType/HotelPage/IntroSection/types.ts @@ -0,0 +1,14 @@ +import { + HotelAddress, + HotelData, + HotelLocation, + HotelTripAdvisor, +} from "@/types/hotel" + +export type IntroSectionProps = { + hotelName: HotelData["data"]["attributes"]["name"] + hotelDescription: HotelData["data"]["attributes"]["hotelContent"]["texts"]["descriptions"]["short"] + location: HotelLocation + address: HotelAddress + tripAdvisor: HotelTripAdvisor +} diff --git a/types/hotel.ts b/types/hotel.ts index 5d5f33b06..da72002ac 100644 --- a/types/hotel.ts +++ b/types/hotel.ts @@ -6,3 +6,5 @@ export type HotelData = z.infer export type HotelAddress = HotelData["data"]["attributes"]["address"] export type HotelLocation = HotelData["data"]["attributes"]["location"] +export type HotelTripAdvisor = + HotelData["data"]["attributes"]["ratings"]["tripAdvisor"]