Router.js (1479B)
1 import Welcome from './guide/Welcome.js' 2 // import GuideStart from './guide/GuideStart.js' 3 // import GuideSteps from './guide/GuideSteps.js' 4 import GridView from './GridView.js' 5 import CuratedView from './CuratedView.js' 6 import SingleView from './SingleView.js' 7 import Login from './Login.js' 8 import WaitingCrunching from './modals/WaitingCrunchingModal.js' 9 import { useTemplatesStore } from '../state/Templates.js' 10 11 // Probably the most basic router you can imagine 12 export default function Router({ page }) { 13 const searchParams = useTemplatesStore(state => state.searchParams) 14 15 // TODO: Possibly we can have a loading screen while we fetch terms, etc 16 if (page === 'main' && !Object.keys(searchParams?.taxonomies ?? {}).length) { 17 page = 'curated' 18 } 19 20 // Reroute the main page depending on the taxonomy and type choices 21 // If no pattern types are selected, show a curated page 22 if (page === 'main' && 23 searchParams?.type === 'pattern' && 24 searchParams?.taxonomies?.tax_pattern_types === '') 25 { 26 page = 'curated' 27 } 28 29 switch (page) { 30 case 'welcome': return <Welcome/> 31 // case 'guide-start': return <GuideStart/> 32 // case 'guide-steps': return <GuideSteps/> 33 case 'waiting-crunching': return <WaitingCrunching/> 34 case 'curated': return <CuratedView/> 35 case 'main': return <GridView/> 36 case 'single': return <SingleView/> 37 case 'login': return <Login/> 38 } 39 }