Feat/SW-2271 hotel list filtering

* feat(SW-2271): Changes to hotel data types in preperation for filtering
* feat(SW-2271): Added filter and sort functionality

Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2025-07-04 09:27:20 +00:00
parent 82e21af0d4
commit fa7214cb58
58 changed files with 1572 additions and 450 deletions

View File

@@ -1,5 +1,6 @@
import { SortOption } from "../../../enums/destinationFilterAndSort"
import { ApiCountry } from "../../../types/country"
import { HotelSortOption } from "../../../types/hotel"
import { getFiltersFromHotels } from "../../../utils/getFiltersFromHotels"
import { getSortedCities } from "../../../utils/getSortedCities"
import {
getCityByCityIdentifier,
@@ -8,7 +9,6 @@ import {
getHotelsByHotelIds,
} from "../../hotels/utils"
import { getCityPages } from "../destinationCountryPage/utils"
import { getFiltersFromHotels } from "./helpers"
import type { Lang } from "@scandic-hotels/common/constants/language"
@@ -61,7 +61,7 @@ export async function getCityData(
let filterType
if (filter) {
const allFilters = getFiltersFromHotels(hotels)
const allFilters = getFiltersFromHotels(hotels, lang)
const facilityFilter = allFilters.facilityFilters.find(
(f) => f.slug === filter
)
@@ -101,7 +101,7 @@ export async function getCountryData(
let filterType
const cities = await getCityPages(lang, serviceToken, country)
const sortedCities = getSortedCities(cities, SortOption.Recommended)
const sortedCities = getSortedCities(cities, HotelSortOption.Recommended)
const hotelIds = await getHotelIdsByCountry({
country,
serviceToken,
@@ -110,7 +110,7 @@ export async function getCountryData(
const hotels = await getHotelsByHotelIds({ hotelIds, lang, serviceToken })
if (filter) {
const allFilters = getFiltersFromHotels(hotels)
const allFilters = getFiltersFromHotels(hotels, lang)
const facilityFilter = allFilters.facilityFilters.find(
(f) => f.slug === filter
)