From 948c86479a8647c3a3b8ff3731fcb35a113218c4 Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Thu, 18 Sep 2025 13:03:01 +0000 Subject: [PATCH] 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) --- .../destination_city_page/[uid]/page.tsx | 7 +-- .../destination_country_page/[uid]/page.tsx | 10 +--- .../CityMap/HotelList/index.tsx | 18 ++++-- .../DestinationCityPage/CityMap/index.tsx | 6 +- .../DestinationCityPage/index.tsx | 15 +---- .../CountryMap/index.tsx | 6 +- .../DestinationCountryPage/index.tsx | 12 +--- .../SidebarContentWrapper/index.tsx | 20 +++++-- .../ContentType/DestinationPage/utils.ts | 13 +++-- .../DestinationFilterAndSort/Filter/index.tsx | 12 ++-- .../DestinationFilterAndSort/index.tsx | 28 ++++++--- .../DestinationDataProvider/Content.tsx | 8 ++- .../DestinationDataProvider/index.tsx | 2 - .../stores/destination-data/helper.ts | 5 +- .../stores/destination-data/index.ts | 58 ++++++++++++------- .../types/stores/destination-data.ts | 15 +++-- packages/trpc/lib/types/hotel.ts | 2 + .../trpc/lib/utils/getFiltersFromHotels.ts | 1 + 18 files changed, 136 insertions(+), 102 deletions(-) diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/(contentTypes)/destination_city_page/[uid]/page.tsx b/apps/scandic-web/app/[lang]/(live)/(public)/(contentTypes)/destination_city_page/[uid]/page.tsx index 60398aebe..179ad13e9 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/(contentTypes)/destination_city_page/[uid]/page.tsx +++ b/apps/scandic-web/app/[lang]/(live)/(public)/(contentTypes)/destination_city_page/[uid]/page.tsx @@ -10,16 +10,13 @@ import type { PageArgs } from "@/types/params" export { generateMetadata } from "@/utils/metadata/generateMetadata" export default async function DestinationCityPagePage( - props: PageArgs + props: PageArgs ) { const searchParams = await props.searchParams return (
}> - +
) diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/(contentTypes)/destination_country_page/[uid]/page.tsx b/apps/scandic-web/app/[lang]/(live)/(public)/(contentTypes)/destination_country_page/[uid]/page.tsx index 534c37e9b..c611404b6 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/(contentTypes)/destination_country_page/[uid]/page.tsx +++ b/apps/scandic-web/app/[lang]/(live)/(public)/(contentTypes)/destination_country_page/[uid]/page.tsx @@ -5,20 +5,16 @@ import DestinationCountryPageSkeleton from "@/components/ContentType/Destination import styles from "./page.module.css" -import type { PageArgs } from "@/types/params" - export { generateMetadata } from "@/utils/metadata/generateMetadata" -export default async function DestinationCountryPagePage( - props: PageArgs -) { - const searchParams = await props.searchParams +export default async function DestinationCountryPagePage() { + // props: PageArgs<{}, { view?: "map"; }> + // const searchParams = await props.searchParams return (
}> diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/HotelList/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/HotelList/index.tsx index c6679877a..3271536ec 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/HotelList/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/HotelList/index.tsx @@ -44,16 +44,24 @@ export default function HotelList() { return } - function handleBoundsChanged() { - debouncedUpdateVisibleHotels() - } - - coreLib.event.addListener(map, "bounds_changed", handleBoundsChanged) + coreLib.event.addListener( + map, + "bounds_changed", + debouncedUpdateVisibleHotels + ) return () => { coreLib.event.clearListeners(map, "bounds_changed") } }, [map, coreLib, debouncedUpdateVisibleHotels]) + useEffect(() => { + if (!map) { + return + } + + setVisibleHotels(getVisibleHotels(activeHotels, map)) + }, [map, activeHotels]) + if (isLoading) { return } diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/index.tsx index 3469ae644..7efddd9a0 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/CityMap/index.tsx @@ -29,11 +29,11 @@ export default function CityMap({ defaultLocation, }: CityMapProps) { const intl = useIntl() - const { activeHotels, allFilters, activeFilters } = useDestinationDataStore( + const { activeHotels, allFilters, filterFromUrl } = useDestinationDataStore( (state) => ({ activeHotels: state.activeHotels, allFilters: state.allFilters, - activeFilters: state.activeFilters, + filterFromUrl: state.filterFromUrl, }) ) @@ -47,7 +47,7 @@ export default function CityMap({ >

- {getHeadingText(intl, city.name, allFilters, activeFilters[0])} + {getHeadingText(intl, city.name, allFilters, filterFromUrl)}

diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/index.tsx index 2bebf8e5d..c0ea35bcc 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/index.tsx @@ -28,7 +28,6 @@ import DestinationPageSidePeek from "../Sidepeek" import StaticMap from "../StaticMap" import TopImages from "../TopImages" import DestinationTracking from "../Tracking" -import { getHeadingText } from "../utils" import CityMap from "./CityMap" import DestinationCityPageSkeleton from "./DestinationCityPageSkeleton" @@ -36,12 +35,10 @@ import styles from "./destinationCityPage.module.css" interface DestinationCityPageProps { isMapView: boolean - filterFromUrl?: string } export default async function DestinationCityPage({ isMapView, - filterFromUrl, }: DestinationCityPageProps) { const intl = await getIntl() const lang = await getLang() @@ -94,7 +91,6 @@ export default async function DestinationCityPage({ @@ -120,16 +116,7 @@ export default async function DestinationCityPage({ {blocks && }