Skip to content

Commit

Permalink
fix: check projectType url param on mount to update btns
Browse files Browse the repository at this point in the history
  • Loading branch information
allison-truhlar committed Jul 24, 2024
1 parent 8ab814d commit 8956248
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/stores/selectedProjectTypeStore.js
Original file line number Diff line number Diff line change
@@ -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") {
Expand Down

0 comments on commit 8956248

Please sign in to comment.