feat(BOOK-54): Adjusted filter functionality to save filters as query parameters instead of paths

* feat(BOOK-54): Destination filters now matching on id instead of slug in preparation for filters from Contentstack

Approved-by: Chuma Mcphoy (We Ahead)
This commit is contained in:
Erik Tiekstra
2025-09-18 13:03:01 +00:00
parent 32a817fa72
commit 948c86479a
18 changed files with 136 additions and 102 deletions

View File

@@ -24,10 +24,14 @@ export default function DestinationDataProviderContent({
const filterParam = searchParams.get("filter")
const filters = []
const pathParts = currentPathname.split("/")
const lastPathPart = pathParts[pathParts.length - 1]
const filterFromUrl = pathParts[pathParts.length - 1]
// Even though the user filter is stored in the query param,
// we also support having it as the last part of the pathname
// e.g. /destination/copenhagen/spa
// In this case we need to add it to the filters array
if (basePath !== currentPathname) {
filters.push(lastPathPart)
filters.push(filterFromUrl)
}
if (filterParam) {
filters.push(...filterParam.split("&"))

View File

@@ -15,7 +15,6 @@ export default function DestinationDataProvider({
allCities = [],
allHotels,
allFilters,
filterFromUrl,
sortItems,
pathname,
children,
@@ -28,7 +27,6 @@ export default function DestinationDataProvider({
allCities,
allHotels,
allFilters,
filterFromUrl,
pathname,
sortItems,
searchParams,