File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { useState } from "react" ;
1+ import { useState , useEffect } from "react" ;
22import styles from "./styles.module.css" ;
33import Section from "../layout/Section" ;
44import CardGrid from "../layout/CardGrid" ;
@@ -18,7 +18,21 @@ export function getCategoryFromProjectPageName(pageName: string) {
1818}
1919
2020export function MainAreaFundableProjects ( ) {
21- const [ active , setActive ] = useState ( "All" ) ;
21+ const [ active , setActive ] = useState ( ( ) => {
22+ if ( typeof window === "undefined" ) return "All" ;
23+ const param = new URLSearchParams ( window . location . search ) . get ( "category" ) ;
24+ return CATEGORIES . includes ( param ) ? param : "All" ;
25+ } ) ;
26+
27+ useEffect ( ( ) => {
28+ const url = new URL ( window . location . href ) ;
29+ if ( active === "All" ) {
30+ url . searchParams . delete ( "category" ) ;
31+ } else {
32+ url . searchParams . set ( "category" , active ) ;
33+ }
34+ window . history . replaceState ( null , "" , url . toString ( ) ) ;
35+ } , [ active ] ) ;
2236
2337 const visible = active === "All"
2438 ? ALL_PROJECTS
You can’t perform that action at this time.
0 commit comments