feat(SW-251): filter request
This commit is contained in:
@@ -23,13 +23,11 @@ export default async function SelectHotelPage({
|
||||
const getHotelFitlers = await serverClient().hotel.filters.get({
|
||||
language: params.lang,
|
||||
country: "Sweden",
|
||||
city: "Halmstad",
|
||||
city: "Helsingborg",
|
||||
})
|
||||
|
||||
if (!getHotelFitlers) return null
|
||||
|
||||
console.log(getHotelFitlers.data)
|
||||
|
||||
const getAvailableHotels = await serverClient().hotel.availability.get({
|
||||
cityId: "8ec4bba3-1c38-4606-82d1-bbe3f6738e54",
|
||||
roomStayStartDate: "2024-11-02",
|
||||
@@ -41,8 +39,6 @@ export default async function SelectHotelPage({
|
||||
|
||||
const { availability } = getAvailableHotels
|
||||
|
||||
console.log(availability)
|
||||
|
||||
return (
|
||||
<main className={styles.main}>
|
||||
<section>
|
||||
|
||||
@@ -4,7 +4,10 @@ import styles from "./hotelFilter.module.css"
|
||||
|
||||
import { HotelFilterProps } from "@/types/components/hotelReservation/selectHotel/hotelFilterProps"
|
||||
|
||||
export default async function HotelFilter({ filters }: HotelFilterProps) {
|
||||
export default async function HotelFilter({
|
||||
hotelId,
|
||||
filters,
|
||||
}: HotelFilterProps) {
|
||||
const { formatMessage } = await getIntl()
|
||||
|
||||
return (
|
||||
|
||||
@@ -145,7 +145,7 @@ const hotelContentSchema = z.object({
|
||||
restaurantsOverviewPageLinkText: z.string(),
|
||||
restaurantsOverviewPageLink: z.string(),
|
||||
restaurantsContentDescriptionShort: z.string(),
|
||||
restaurantsContentDescriptionMedium: z.string(),
|
||||
restaurantsContentDescriptionMedium: z.string().optional(),
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -551,7 +551,6 @@ const rate = z.object({
|
||||
})
|
||||
|
||||
export const getRatesSchema = z.array(rate)
|
||||
|
||||
export type Rate = z.infer<typeof rate>
|
||||
|
||||
const hotelFilterSchema = z.object({
|
||||
@@ -566,7 +565,7 @@ const hotelFilterSchema = z.object({
|
||||
ratings: ratingsSchema,
|
||||
address: addressSchema,
|
||||
location: locationSchema,
|
||||
hotelContent: hotelContentSchema,
|
||||
hotelContent: hotelContentSchema.optional(),
|
||||
detailedFacilities: z.array(detailedFacilitySchema),
|
||||
isActive: z.boolean(),
|
||||
}),
|
||||
@@ -580,3 +579,6 @@ const hotelFilterSchema = z.object({
|
||||
|
||||
export const getHotelFilterSchema = hotelFilterSchema
|
||||
export type HotelFilter = z.infer<typeof hotelFilterSchema>
|
||||
export type HotelId = HotelFilter["data"][number]["id"]
|
||||
export type HotelFilters =
|
||||
HotelFilter["data"][number]["attributes"]["detailedFacilities"]
|
||||
|
||||
@@ -38,7 +38,6 @@ import {
|
||||
getRatesSchema,
|
||||
roomSchema,
|
||||
} from "./output"
|
||||
import tempFilterData from "./tempFilterData.json"
|
||||
import tempRatesData from "./tempRatesData.json"
|
||||
|
||||
import { HotelBlocksTypenameEnum } from "@/types/components/hotelPage/enums"
|
||||
@@ -515,7 +514,19 @@ export const hotelQueryRouter = router({
|
||||
"api.hotels.fuilters success",
|
||||
JSON.stringify({ query: { params: params } })
|
||||
)
|
||||
return validateFilterData.data
|
||||
|
||||
const hotelData = validateFilterData.data.data
|
||||
const filters = hotelData.flatMap(
|
||||
(data) => data.attributes.detailedFacilities
|
||||
)
|
||||
const unieqId = [...new Set(filters.map((data) => data.id))]
|
||||
|
||||
return {
|
||||
hotelId: hotelData.map((data) => data.id),
|
||||
filters: unieqId.map((data) =>
|
||||
filters.find((find) => find.id === data)
|
||||
),
|
||||
}
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"roomFacilities": ["Balcony", "Bathub", "View", "Conntecting doors"],
|
||||
"hotelFacilities": [
|
||||
"Parking inside",
|
||||
"Parking outside",
|
||||
"Parking electric",
|
||||
"Sauna",
|
||||
"Pool",
|
||||
"Restaurant",
|
||||
"Bar",
|
||||
"Sky/rooftop bar",
|
||||
"Gym",
|
||||
"Coworking"
|
||||
],
|
||||
"hotelSurroundings": [
|
||||
"Beach",
|
||||
"Lake or sea",
|
||||
"Hiking",
|
||||
"Mountains",
|
||||
"Golf course"
|
||||
]
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
import { HotelFilter } from "@/server/routers/hotels/output"
|
||||
import { HotelFilters, HotelId } from "@/server/routers/hotels/output"
|
||||
|
||||
export type HotelFilterProps = { filters: HotelFilter }
|
||||
export type HotelFilterProps = {
|
||||
hotelId: HotelId
|
||||
filters: HotelFilters
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user