From 655ec610fcce8dd7748f10772d520bdff4f7c78e Mon Sep 17 00:00:00 2001
From: Arne Rief <riearn@proton.me>
Date: Fri, 19 Dec 2025 20:03:03 +0100
Subject: Basic setup & login

---
 frontend/src/components/ProtectedRoute.tsx | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 frontend/src/components/ProtectedRoute.tsx

(limited to 'frontend/src/components/ProtectedRoute.tsx')

diff --git a/frontend/src/components/ProtectedRoute.tsx b/frontend/src/components/ProtectedRoute.tsx
new file mode 100644
index 0000000..a9d233c
--- /dev/null
+++ b/frontend/src/components/ProtectedRoute.tsx
@@ -0,0 +1,18 @@
+import type { ReactNode } from "react";
+import { Navigate } from "react-router-dom";
+
+type Props = {
+    children: ReactNode;
+};
+
+function ProtectedRoute({ children }: Props) {
+    const token = localStorage.getItem("token-robot-tracker");
+
+    if (!token || token === "undefined" || token === "null") {
+        return <Navigate to="/login" replace />;
+    }
+
+    return children;
+}
+
+export default ProtectedRoute;
-- 
cgit v1.2.3

