-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
succesfully converted to file based routng
- Loading branch information
Showing
20 changed files
with
992 additions
and
1,942 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,38 @@ | ||
import { Outlet, RootRoute, Route, Router } from '@tanstack/react-router'; | ||
// import { TanStackRouterDevtools } from "@tanstack/router-devtools"; | ||
import { QueryClient } from '@tanstack/react-query'; | ||
import { createRouter } from '@tanstack/react-router'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
|
||
import App from './App.tsx'; | ||
import './index.css'; | ||
import Home from './pages/Home.tsx'; | ||
import Hosting from './pages/Hosting'; | ||
import NewListingOnboarding from './pages/Hosting/NewListing/index.tsx'; | ||
import RoomPage from './pages/Room/index.tsx'; | ||
import Wishlist from './pages/Wishlists.tsx'; | ||
|
||
// eslint-disable-next-line react-refresh/only-export-components | ||
function Root() { | ||
return ( | ||
<div | ||
style={{ | ||
alignItems: 'center', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
<Outlet /> | ||
{/* <TanStackRouterDevtools initialIsOpen={false} /> */} | ||
</div> | ||
); | ||
} | ||
const rootRoute = new RootRoute({ | ||
component: Root, | ||
}); | ||
|
||
// Create an index route | ||
const indexRoute = new Route({ | ||
component: Home, | ||
getParentRoute: () => rootRoute, | ||
path: '/', | ||
}); | ||
export const hostingRoute = new Route({ | ||
component: Hosting, | ||
getParentRoute: () => rootRoute, | ||
path: 'hosting', | ||
}); | ||
|
||
export const newListingOnboard = new Route({ | ||
component: NewListingOnboarding, | ||
getParentRoute: () => rootRoute, | ||
path: 'listing', | ||
import { routeTree } from './routeTree.gen'; | ||
|
||
// Create a new router instance | ||
const queryClient = new QueryClient(); | ||
|
||
// Set up a Router instance | ||
const router = createRouter({ | ||
context: { | ||
queryClient, | ||
}, | ||
defaultPreload: 'intent', | ||
// This will ensure that the loader is always called when the route is preloaded or visited | ||
defaultPreloadStaleTime: 0, | ||
// Since we're using React Query, we don't want loader calls to ever be stale | ||
routeTree, | ||
}); | ||
|
||
export const wishListRoute = new Route({ | ||
component: Wishlist, | ||
getParentRoute: () => rootRoute, | ||
path: 'wishlists', | ||
}); | ||
|
||
export const roomsRoute = new Route({ | ||
component: RoomPage, | ||
getParentRoute: () => rootRoute, | ||
path: 'rooms', | ||
}); | ||
export const roomRoute = new Route({ | ||
component: RoomPage, | ||
getParentRoute: () => roomsRoute, | ||
path: '$roomId', | ||
}); | ||
const routeTree = rootRoute.addChildren([ | ||
indexRoute, | ||
wishListRoute, | ||
roomsRoute.addChildren([roomRoute]), | ||
hostingRoute.addChildren([newListingOnboard]), | ||
]); | ||
|
||
// Create the router using your route tree | ||
const router = new Router({ routeTree }); | ||
|
||
// Register your router for maximum type safety | ||
// Register the router instance for type safety | ||
declare module '@tanstack/react-router' { | ||
interface Register { | ||
router: typeof router; | ||
} | ||
} | ||
|
||
export type IRouter = typeof router; | ||
|
||
ReactDOM.createRoot(document.getElementById('root')!).render( | ||
ReactDOM.createRoot(document.getElementById('app')!).render( | ||
<React.StrictMode> | ||
<App router={router} /> | ||
</React.StrictMode> | ||
</React.StrictMode>, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,39 @@ | ||
import { useNavigate } from "@tanstack/react-router"; | ||
import { useEffect } from "react"; | ||
|
||
import { Footer } from "../components/Footer"; | ||
import HomeResults from "../components/HomeResults"; | ||
import StickyHeader from "../components/StickyHeader"; | ||
import { getLocalStorage } from "../utils/LocalStorage"; | ||
import { Footer } from '@/components/Footer'; | ||
import HomeResults from '@/components/HomeResults'; | ||
import StickyHeader from '@/components/StickyHeader'; | ||
import { styled } from '@/stitches.config'; | ||
import { getLocalStorage } from '@/utils/LocalStorage'; | ||
import { useNavigate } from '@tanstack/react-router'; | ||
import { useEffect } from 'react'; | ||
|
||
function Home() { | ||
|
||
const navigate = useNavigate(); | ||
|
||
useEffect(() => { | ||
const redirectUri = getLocalStorage('redirectTo') | ||
console.log(redirectUri) | ||
const redirectUri = getLocalStorage('redirectTo'); | ||
if (redirectUri) { | ||
navigate({ to: redirectUri }); | ||
localStorage.removeItem('redirectTo'); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []) | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<Container> | ||
<StickyHeader /> | ||
<HomeResults /> | ||
<Footer /> | ||
</> | ||
</Container> | ||
); | ||
} | ||
|
||
export default Home; | ||
|
||
const Container = styled('div', { | ||
alignItems: 'center', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
height: '100%', | ||
justifyContent: 'center', | ||
width: '100%', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.