summaryrefslogtreecommitdiff
path: root/makima/frontend/src/routes/files.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'makima/frontend/src/routes/files.tsx')
-rw-r--r--makima/frontend/src/routes/files.tsx32
1 files changed, 32 insertions, 0 deletions
diff --git a/makima/frontend/src/routes/files.tsx b/makima/frontend/src/routes/files.tsx
index 0645b85..3ba2d52 100644
--- a/makima/frontend/src/routes/files.tsx
+++ b/makima/frontend/src/routes/files.tsx
@@ -14,8 +14,40 @@ import {
} from "../hooks/useFileSubscription";
import type { FileDetail as FileDetailType, BodyElement, Task } from "../lib/api";
import { createTask } from "../lib/api";
+import { useAuth } from "../contexts/AuthContext";
export default function FilesPage() {
+ const { isAuthenticated, isAuthConfigured, isLoading: authLoading } = useAuth();
+ const navigate = useNavigate();
+
+ // Redirect to login if not authenticated (when auth is configured)
+ useEffect(() => {
+ if (!authLoading && isAuthConfigured && !isAuthenticated) {
+ navigate("/login");
+ }
+ }, [authLoading, isAuthConfigured, isAuthenticated, navigate]);
+
+ // Show loading while checking auth
+ if (authLoading) {
+ return (
+ <div className="relative z-10 min-h-screen flex flex-col bg-[#0a1628]">
+ <Masthead showNav />
+ <main className="flex-1 flex items-center justify-center">
+ <p className="text-[#7788aa] font-mono text-sm">Loading...</p>
+ </main>
+ </div>
+ );
+ }
+
+ // Don't render if not authenticated (will redirect)
+ if (isAuthConfigured && !isAuthenticated) {
+ return null;
+ }
+
+ return <FilesPageContent />;
+}
+
+function FilesPageContent() {
const { id } = useParams<{ id: string }>();
const navigate = useNavigate();
const { files, loading, error, conflict, clearConflict, fetchFile, editFile, removeFile, saveFile } = useFiles();