From 895624862aba51b91f25994911f01676b8c0ea58 Mon Sep 17 00:00:00 2001 From: Allison Truhlar Date: Wed, 24 Jul 2024 09:16:55 -0400 Subject: [PATCH] fix: check projectType url param on mount to update btns --- src/stores/selectedProjectTypeStore.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/stores/selectedProjectTypeStore.js b/src/stores/selectedProjectTypeStore.js index bca6562d..05c6b3ff 100644 --- a/src/stores/selectedProjectTypeStore.js +++ b/src/stores/selectedProjectTypeStore.js @@ -1,7 +1,19 @@ -import { atom } from "nanostores"; +import { atom, onMount } from "nanostores"; export const selectedProjectType = atom([]); +onMount(selectedProjectType, () => { + const currentProjectType = selectedProjectType.get(); + let urlProjectType = []; + if (typeof window !== "undefined") { + const searchParams = new URLSearchParams(window.location.search); + urlProjectType = searchParams.getAll("projectType"); + } + if ((currentProjectType.length === 0) & (urlProjectType.length > 0)) { + selectedProjectType.set(urlProjectType); + } +}); + function updateProjectTypeSearchParams(updatedProjectType) { // update URL search params if (typeof window !== "undefined") {