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