feat/SW-627-query-available-hotels (pull request #751)
Feat/SW-627 query available hotels * feat(SW-627): use correct search query to find available hotels * feat(SW-627): fix type name * feat(SW-627): update correct params * feat(SW-627): update correct params type * feat(SW-627): fix select hotel searchParams type Approved-by: Niclas Edenvin
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
import { selectHotelMap } from "@/constants/routes/hotelReservation"
|
||||
import { getLocations } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import {
|
||||
fetchAvailableHotels,
|
||||
@@ -6,6 +9,7 @@ import {
|
||||
} from "@/app/[lang]/(live)/(public)/hotelreservation/(standard)/select-hotel/utils"
|
||||
import HotelCardListing from "@/components/HotelReservation/HotelCardListing"
|
||||
import HotelFilter from "@/components/HotelReservation/SelectHotel/HotelFilter"
|
||||
import getHotelReservationQueryParams from "@/components/HotelReservation/SelectRate/RoomSelection/utils"
|
||||
import { ChevronRightIcon } from "@/components/Icons"
|
||||
import StaticMap from "@/components/Maps/StaticMap"
|
||||
import Link from "@/components/TempDesignSystem/Link"
|
||||
@@ -14,21 +18,38 @@ import { setLang } from "@/i18n/serverContext"
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import type { SelectHotelSearchParams } from "@/types/components/hotelReservation/selectHotel/selectHotelSearchParams"
|
||||
import { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function SelectHotelPage({
|
||||
params,
|
||||
}: PageArgs<LangParams>) {
|
||||
searchParams,
|
||||
}: PageArgs<LangParams, SelectHotelSearchParams>) {
|
||||
setLang(params.lang)
|
||||
const locations = await getLocations()
|
||||
|
||||
if (!locations || "error" in locations) {
|
||||
return null
|
||||
}
|
||||
const city = locations.data.find(
|
||||
(location) =>
|
||||
location.name.toLowerCase() === searchParams.city.toLowerCase()
|
||||
)
|
||||
if (!city) return notFound()
|
||||
|
||||
const tempSearchTerm = "Stockholm"
|
||||
const intl = await getIntl()
|
||||
const selectHotelParams = new URLSearchParams(searchParams)
|
||||
const selectHotelParamsObject =
|
||||
getHotelReservationQueryParams(selectHotelParams)
|
||||
const adults = selectHotelParamsObject.room[0].adults // TODO: Handle multiple rooms
|
||||
const children = selectHotelParamsObject.room[0].child?.length // TODO: Handle multiple rooms
|
||||
|
||||
const hotels = await fetchAvailableHotels({
|
||||
cityId: "8ec4bba3-1c38-4606-82d1-bbe3f6738e54",
|
||||
roomStayStartDate: "2024-11-02",
|
||||
roomStayEndDate: "2024-11-03",
|
||||
adults: 1,
|
||||
cityId: city.id,
|
||||
roomStayStartDate: searchParams.fromDate,
|
||||
roomStayEndDate: searchParams.toDate,
|
||||
adults,
|
||||
children,
|
||||
})
|
||||
|
||||
const filterList = getFiltersFromHotels(hotels)
|
||||
@@ -38,12 +59,12 @@ export default async function SelectHotelPage({
|
||||
<section className={styles.section}>
|
||||
<Link href={selectHotelMap[params.lang]} keepSearchParams>
|
||||
<StaticMap
|
||||
city={tempSearchTerm}
|
||||
city={searchParams.city}
|
||||
width={340}
|
||||
height={180}
|
||||
zoomLevel={11}
|
||||
mapType="roadmap"
|
||||
altText={`Map of ${tempSearchTerm} city center`}
|
||||
altText={`Map of ${searchParams.city} city center`}
|
||||
/>
|
||||
</Link>
|
||||
<Link
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
interface Child {
|
||||
bed: string
|
||||
age: number
|
||||
}
|
||||
|
||||
interface Room {
|
||||
adults: number
|
||||
child?: Child[]
|
||||
}
|
||||
|
||||
export interface SelectHotelSearchParams {
|
||||
city: string
|
||||
fromDate: string
|
||||
toDate: string
|
||||
room: Room[]
|
||||
[key: string]: string | string[] | Room[]
|
||||
}
|
||||
@@ -14,8 +14,8 @@ interface Room {
|
||||
|
||||
export interface SelectRateSearchParams {
|
||||
hotel: string
|
||||
fromdate: string
|
||||
todate: string
|
||||
fromDate: string
|
||||
toDate: string
|
||||
room: Room[]
|
||||
[key: string]: string | string[] | Room[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user