fix: enable localization of sidepeek params

This commit is contained in:
Arvid Norlin
2024-08-12 10:52:29 +02:00
parent 47c77b62d6
commit 04eb3c6d94
7 changed files with 49 additions and 9 deletions

View File

@@ -1,3 +1,6 @@
import { Lang } from "@/constants/languages"
import { amenities } from "@/constants/routes/hotelPageParams"
import { mapFacilityToIcon } from "@/components/ContentType/HotelPage/data"
import { ChevronRightIcon } from "@/components/Icons"
import Link from "@/components/TempDesignSystem/Link"
@@ -12,11 +15,14 @@ import { HotelData } from "@/types/hotel"
export default async function AmenitiesList({
detailedFacilities,
// TODO: remove prop drilling once getLang() is merged
lang,
}: {
detailedFacilities: HotelData["data"]["attributes"]["detailedFacilities"]
lang: Lang
}) {
const { formatMessage } = await getIntl()
const sidePeekLink = generateSidePeekLink("amenities")
const sidePeekLink = generateSidePeekLink(amenities[lang])
const sortedAmenities = detailedFacilities
.sort((a, b) => b.sortOrder - a.sortOrder)
.slice(0, 5)

View File

@@ -1,3 +1,4 @@
import { about, amenities } from "@/constants/routes/hotelPageParams"
import { serverClient } from "@/lib/trpc/server"
import { getLang } from "@/i18n/serverContext"
@@ -34,6 +35,8 @@ export default async function HotelPage() {
<main className={styles.mainSection}>
<div className={styles.introContainer}>
<IntroSection
// TODO: remove prop drilling once getLang() is merged
lang={lang}
hotelName={attributes.name}
hotelDescription={attributes.hotelContent.texts.descriptions.short}
location={attributes.location}
@@ -55,7 +58,10 @@ export default async function HotelPage() {
Some additional information about the hotel
</SidePeekContent>
</SidePeekContainer>
<AmenitiesList detailedFacilities={attributes.detailedFacilities} />
<AmenitiesList
detailedFacilities={attributes.detailedFacilities}
lang={lang}
/>
</div>
<Rooms rooms={roomCategories} />
</main>

View File

@@ -1,3 +1,5 @@
import { about } from "@/constants/routes/hotelPageParams"
import ArrowRight from "@/components/Icons/ArrowRight"
import TripAdvisorIcon from "@/components/Icons/TripAdvisor"
import Link from "@/components/TempDesignSystem/Link"
@@ -18,6 +20,8 @@ export default async function IntroSection({
location,
address,
tripAdvisor,
// TODO: remove prop drilling once getLang() is merged
lang,
}: IntroSectionProps) {
const intl = await getIntl()
const { formatMessage } = intl
@@ -32,7 +36,7 @@ export default async function IntroSection({
{ id: "Tripadvisor reviews" },
{ rating: tripAdvisor.rating, count: tripAdvisor.numberOfReviews }
)
const aboutTheHotelLink = generateSidePeekLink("about")
const aboutTheHotelLink = generateSidePeekLink(about[lang])
return (
<section className={styles.introSection}>

View File

@@ -1,3 +1,5 @@
import { Lang } from "@/constants/languages"
import {
HotelAddress,
HotelData,
@@ -11,4 +13,6 @@ export type IntroSectionProps = {
location: HotelLocation
address: HotelAddress
tripAdvisor: HotelTripAdvisor
// TODO: remove prop drilling once getLang() is merged
lang: Lang
}