From c29d3c2f933e6b3d7ddf97199295cd17242a05d5 Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Tue, 25 Mar 2025 14:50:34 +0000 Subject: [PATCH] feat(SW-1907): Not rendering blocks when at least one filter is active on destination pages Approved-by: Christian Andolf --- .../DestinationPage/Blocks/index.tsx | 43 +++++++++++++++++++ .../DestinationCityPage/index.tsx | 2 +- .../DestinationCountryPage/index.tsx | 2 +- 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 apps/scandic-web/components/ContentType/DestinationPage/Blocks/index.tsx diff --git a/apps/scandic-web/components/ContentType/DestinationPage/Blocks/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/Blocks/index.tsx new file mode 100644 index 000000000..719762b7e --- /dev/null +++ b/apps/scandic-web/components/ContentType/DestinationPage/Blocks/index.tsx @@ -0,0 +1,43 @@ +"use client" + +import { useDestinationDataStore } from "@/stores/destination-data" + +import AccordionSection from "@/components/Blocks/Accordion" +import JsonToHtml from "@/components/JsonToHtml" + +import type { BlocksProps } from "@/types/components/blocks" +import { BlocksEnums } from "@/types/enums/blocks" + +export default function Blocks({ blocks }: BlocksProps) { + const { activeFilters } = useDestinationDataStore((state) => ({ + activeFilters: state.activeFilters, + })) + + if (activeFilters.length) { + return null + } + + return blocks.map((block, idx) => { + switch (block.typename) { + case BlocksEnums.block.Accordion: + return ( + + ) + case BlocksEnums.block.Content: + return ( +
+ +
+ ) + default: + return null + } + }) +} diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/index.tsx index 98f050c2f..6f4f5e23a 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/index.tsx @@ -4,10 +4,10 @@ import { Suspense } from "react" import { env } from "@/env/server" import { getDestinationCityPage } from "@/lib/trpc/memoizedRequests" -import Blocks from "@/components/Blocks" import Breadcrumbs from "@/components/Breadcrumbs" import BreadcrumbsSkeleton from "@/components/TempDesignSystem/Breadcrumbs/BreadcrumbsSkeleton" +import Blocks from "../Blocks" import ExperienceList from "../ExperienceList" import HotelDataContainer, { preload } from "../HotelDataContainer" import HotelListing from "../HotelListing" diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/index.tsx index cb109137b..567277e46 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/index.tsx @@ -3,10 +3,10 @@ import { Suspense } from "react" import { getDestinationCountryPage } from "@/lib/trpc/memoizedRequests" -import Blocks from "@/components/Blocks" import Breadcrumbs from "@/components/Breadcrumbs" import BreadcrumbsSkeleton from "@/components/TempDesignSystem/Breadcrumbs/BreadcrumbsSkeleton" +import Blocks from "../Blocks" import CityDataContainer, { preload } from "../CityDataContainer" import CityListing from "../CityListing" import ExperienceList from "../ExperienceList"