-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9471fe0
commit 2ec7203
Showing
11 changed files
with
119 additions
and
61 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
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { createRouter, RouterProvider } from "@tanstack/react-router"; | ||
import { queryClient } from "./integrations/network"; | ||
import { routeTree } from "./routeTree.gen"; | ||
import { useAuthStore } from "./store/auth"; | ||
|
||
const router = createRouter({ | ||
routeTree, | ||
context: { | ||
queryClient, | ||
auth: undefined!, | ||
}, | ||
defaultPreload: "intent", | ||
defaultPreloadStaleTime: 0, | ||
}); | ||
|
||
declare module "@tanstack/react-router" { | ||
interface Register { | ||
router: typeof router; | ||
} | ||
} | ||
|
||
export const App = () => { | ||
const authState = useAuthStore(); | ||
return <RouterProvider router={router} context={{ auth: authState }} />; | ||
}; |
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,5 +1,13 @@ | ||
import { createFileRoute } from "@tanstack/react-router"; | ||
import { createFileRoute, redirect } from "@tanstack/react-router"; | ||
|
||
export const Route = createFileRoute("/_auth")({ | ||
component: () => <div>Hello /_auth!</div>, | ||
beforeLoad: ({ context }) => { | ||
if (!context.auth.isAuthenticated) | ||
throw redirect({ | ||
to: "/signin", | ||
search: { | ||
redirect: location.href, | ||
}, | ||
}); | ||
}, | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { createFileRoute } from "@tanstack/react-router"; | ||
import { useAuth } from "../../apis/hooks/auth"; | ||
|
||
export const Route = createFileRoute("/_auth/dashboard")({ | ||
component: Dashboard, | ||
}); | ||
|
||
function Dashboard() { | ||
const { signOut } = useAuth(); | ||
|
||
return ( | ||
<div> | ||
<button onClick={signOut}>SignOut</button> | ||
</div> | ||
); | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
import { createFileRoute } from "@tanstack/react-router"; | ||
import { useAuth } from "../apis/hooks/auth"; | ||
|
||
export const Route = createFileRoute("/signin")({ | ||
component: Login, | ||
component: SignIn, | ||
}); | ||
|
||
function Login() { | ||
return <div>Login</div>; | ||
function SignIn() { | ||
const { signIn } = useAuth(); | ||
|
||
return ( | ||
<div> | ||
<button onClick={signIn}>Google Login</button> | ||
</div> | ||
); | ||
} |
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