diff --git a/src/app/FilterProviderWrapper.tsx b/src/app/FilterProviderWrapper.tsx new file mode 100644 index 00000000..4589fe65 --- /dev/null +++ b/src/app/FilterProviderWrapper.tsx @@ -0,0 +1,11 @@ +"use client"; + +import { FilterProvider } from "@/context/FilterContext"; + +export const FilterProviderWrapper = ({ + children, +}: { + children: React.ReactNode; +}) => { + return {children} +} \ No newline at end of file diff --git a/src/app/find-properties/[[...opa_id]]/page.tsx b/src/app/find-properties/[[...opa_id]]/page.tsx index 7aad81ac..ece48965 100644 --- a/src/app/find-properties/[[...opa_id]]/page.tsx +++ b/src/app/find-properties/[[...opa_id]]/page.tsx @@ -208,7 +208,6 @@ const MapPage = ({ params }: MapPageProps) => { }, [currentView, selectedProperty, shouldFilterSavedProperties]); return ( -
@@ -321,7 +320,6 @@ const MapPage = ({ params }: MapPageProps) => {
-
); }; diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 2860d06a..8a4e65f0 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,6 +1,7 @@ import type { Metadata } from "next"; import "./globals.css"; import { CookieProviderWrapper } from "./CookieProviderWrapper"; +import { FilterProviderWrapper } from "./FilterProviderWrapper"; export const metadata: Metadata = { title: { @@ -29,7 +30,11 @@ export default function RootLayout({ > Skip to main content - {children} + + + {children} + + ); diff --git a/src/components/Filters/DimensionFilter.tsx b/src/components/Filters/DimensionFilter.tsx index 9d3bdb67..893ae9a6 100644 --- a/src/components/Filters/DimensionFilter.tsx +++ b/src/components/Filters/DimensionFilter.tsx @@ -25,8 +25,15 @@ const DimensionFilter: FC = ({ const [selectedKeys, setSelectedKeys] = useState( appFilter[property]?.values || [] ); - const [selectedPanelKeys, setSelectedPanelkeys] = useState<{[property: string]: string[]}>({}) - + const initialSelectedPanelKeys = () => { + let panelKeyObj: {[key: string]: string[]} = {} + for (const key in appFilter) { + panelKeyObj[key] = appFilter[key].values + } + return panelKeyObj + } + const [selectedPanelKeys, setSelectedPanelkeys] = useState<{[property: string]: string[]}>(initialSelectedPanelKeys()) + const toggleDimensionForPanel = (dimension: string, panel_property: string) => { let newSelectedPanelKeys if (selectedPanelKeys[panel_property]) { diff --git a/src/components/SidePanelControlBar.tsx b/src/components/SidePanelControlBar.tsx index e7c08c11..fe3d9f8c 100644 --- a/src/components/SidePanelControlBar.tsx +++ b/src/components/SidePanelControlBar.tsx @@ -1,6 +1,6 @@ "use client"; -import React, { FC, useRef } from "react"; +import React, { FC, useMemo, useRef } from "react"; import { BarClickOptions } from "@/app/find-properties/[[...opa_id]]/page"; import { BookmarkSimple, DownloadSimple, Funnel } from "@phosphor-icons/react"; import { ThemeButton } from "./ThemeButton"; @@ -32,12 +32,20 @@ const SearchBarComponent: FC = ({ const savedRef = useRef(null); const { dispatch, appFilter } = useFilter(); - let filterCount = Object.keys(appFilter).length; - - if (shouldFilterSavedProperties) { - // Exclude opa_id from filterCount, which counts opa_id as a filter by default - filterCount--; - } + const filterCount: number = useMemo(() => { + let count = 0 + for (let property of Object.keys(appFilter)) { + if (property === "access_process") { + count += appFilter[property].values.length + } else { + count++ + } + } + if (shouldFilterSavedProperties) { + count-- + } + return count + }, [appFilter]) const onClickSavedButton = () => { let propertyIds = getPropertyIdsFromLocalStorage();