feat(SW-251): filter request
This commit is contained in:
@@ -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"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user