diff options
| author | soryu <soryu@soryu.co> | 2026-01-11 03:43:10 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-01-11 03:43:10 +0000 |
| commit | 3d15ec753f93babcc1fa0cf3958f1f164e98fea4 (patch) | |
| tree | c75eac7455c4714497e67df82725c47d588ebcb3 /makima/frontend/src/routes/files.tsx | |
| parent | 8b17a175c3e7e27b789812eba4e3cd760beadb10 (diff) | |
| download | soryu-3d15ec753f93babcc1fa0cf3958f1f164e98fea4.tar.gz soryu-3d15ec753f93babcc1fa0cf3958f1f164e98fea4.zip | |
Disable buttons if logged out
Also add prod.env for FE config
Diffstat (limited to 'makima/frontend/src/routes/files.tsx')
| -rw-r--r-- | makima/frontend/src/routes/files.tsx | 32 |
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(); |
