diff options
Diffstat (limited to 'frontend/app/components/PublicOnlyRoute.tsx')
| -rw-r--r-- | frontend/app/components/PublicOnlyRoute.tsx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/frontend/app/components/PublicOnlyRoute.tsx b/frontend/app/components/PublicOnlyRoute.tsx new file mode 100644 index 0000000..2527918 --- /dev/null +++ b/frontend/app/components/PublicOnlyRoute.tsx @@ -0,0 +1,16 @@ +import { Redirect } from "wouter"; +import { useAuth } from "../hooks/useAuth"; + +export default function PublicOnlyRoute({ + children, +}: { + children: React.ReactNode; +}) { + const { isLoggedIn } = useAuth(); + + if (isLoggedIn) { + return <Redirect to="/dashboard" />; + } + + return <>{children}</>; +} |
