feat(SW-1730): add button to room sidepeek on hotelpage to select rate page for the hotel

This commit is contained in:
Michael Zetterberg
2025-03-14 14:19:12 +01:00
parent 540402b969
commit 33239f1f91
4 changed files with 32 additions and 13 deletions

View File

@@ -1,5 +1,8 @@
import Link from "next/link" import Link from "next/link"
import { selectRateWithParams } from "@/constants/routes/hotelReservation"
import { dt } from "@/lib/dt"
import ImageGallery from "@/components/ImageGallery" import ImageGallery from "@/components/ImageGallery"
import { getBedIcon } from "@/components/SidePeeks/RoomSidePeek/bedIcon" import { getBedIcon } from "@/components/SidePeeks/RoomSidePeek/bedIcon"
import { getFacilityIcon } from "@/components/SidePeeks/RoomSidePeek/facilityIcon" import { getFacilityIcon } from "@/components/SidePeeks/RoomSidePeek/facilityIcon"
@@ -9,6 +12,7 @@ import Body from "@/components/TempDesignSystem/Text/Body"
import Caption from "@/components/TempDesignSystem/Text/Caption" import Caption from "@/components/TempDesignSystem/Text/Caption"
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
import { getIntl } from "@/i18n" import { getIntl } from "@/i18n"
import { getLang } from "@/i18n/serverContext"
import { mapApiImagesToGalleryImages } from "@/utils/imageGallery" import { mapApiImagesToGalleryImages } from "@/utils/imageGallery"
import { getRoomNameAsParam } from "../../utils" import { getRoomNameAsParam } from "../../utils"
@@ -17,15 +21,21 @@ import styles from "./room.module.css"
import type { RoomSidePeekProps } from "@/types/components/hotelPage/sidepeek/room" import type { RoomSidePeekProps } from "@/types/components/hotelPage/sidepeek/room"
export default async function RoomSidePeek({ room }: RoomSidePeekProps) { export default async function RoomSidePeek({
hotelId,
room,
}: RoomSidePeekProps) {
const lang = getLang()
const intl = await getIntl() const intl = await getIntl()
const { roomSize, totalOccupancy, descriptions, images } = room const { roomSize, totalOccupancy, descriptions, images } = room
const roomDescription = descriptions.medium const roomDescription = descriptions.medium
// TODO: Not defined where this should lead.
const ctaUrl = ""
const galleryImages = mapApiImagesToGalleryImages(images) const galleryImages = mapApiImagesToGalleryImages(images)
const fromdate = dt().format("YYYY-MM-DD")
const todate = dt().add(1, "day").format("YYYY-MM-DD")
const selectRateURL = selectRateWithParams(lang, hotelId, fromdate, todate)
return ( return (
<SidePeek <SidePeek
contentKey={`room-${getRoomNameAsParam(room.name)}`} contentKey={`room-${getRoomNameAsParam(room.name)}`}
@@ -135,15 +145,13 @@ export default async function RoomSidePeek({ room }: RoomSidePeekProps) {
</ul> </ul>
</div> </div>
</div> </div>
{ctaUrl && (
<div className={styles.buttonContainer}> <div className={styles.buttonContainer}>
<Button fullWidth theme="base" intent="primary" asChild> <Button theme="base" intent="primary" asChild>
<Link href={ctaUrl}> <Link href={selectRateURL}>
{intl.formatMessage({ id: "Select room" })} {intl.formatMessage({ id: "Prices & availability" })}
</Link> </Link>
</Button> </Button>
</div> </div>
)}
</SidePeek> </SidePeek>
) )
} }

View File

@@ -271,7 +271,7 @@ export default async function HotelPage({ hotelId }: HotelPageProps) {
/> />
)} )}
{roomCategories.map((room) => ( {roomCategories.map((room) => (
<RoomSidePeek key={room.name} room={room} /> <RoomSidePeek key={room.name} hotelId={hotelId} room={room} />
))} ))}
</SidePeeks> </SidePeeks>
<Suspense fallback={null}> <Suspense fallback={null}>

View File

@@ -44,6 +44,16 @@ export function selectRate(lang) {
return `${hotelreservation(lang)}/select-rate` return `${hotelreservation(lang)}/select-rate`
} }
/**
* @param {Lang} lang
* @param {string} hotelId
* @param {string} fromdate
* @param {string} todate
*/
export function selectRateWithParams(lang, hotelId, fromdate, todate) {
return `${hotelreservation(lang)}/select-rate?room%5B0%5D.adults=1&fromdate=${fromdate}&todate=${todate}&hotel=${hotelId}`
}
/** /**
* @param {Lang} lang * @param {Lang} lang
*/ */

View File

@@ -2,4 +2,5 @@ import type { Room } from "@/types/hotel"
export interface RoomSidePeekProps { export interface RoomSidePeekProps {
room: Room room: Room
hotelId: string
} }