mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-05 16:37:46 +00:00
67c7078128
- Move NodeProvider inside the authenticated branch in App.tsx so it only mounts after auth is confirmed; previously it mounted on boot causing refreshNodes to fire before any session existed - Replace window.location.href='/' on 401 in apiFetch with a sencho-unauthorized custom event; AuthContext listens and transitions appStatus to notAuthenticated without a full browser reload
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { AuthProvider, useAuth } from './context/AuthContext';
|
|
import { NodeProvider } from './context/NodeContext';
|
|
import { Login } from './components/Login';
|
|
import { Setup } from './components/Setup';
|
|
import EditorLayout from './components/EditorLayout';
|
|
|
|
function AppContent() {
|
|
const { appStatus, isAuthenticated, needsSetup, completeSetup } = useAuth();
|
|
|
|
if (appStatus === 'loading') {
|
|
return (
|
|
<div className="min-h-screen flex items-center justify-center bg-background">
|
|
<div className="text-muted-foreground">Loading...</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (needsSetup) {
|
|
return (
|
|
<div className="min-h-screen flex items-center justify-center bg-background p-4">
|
|
<Setup className="w-full max-w-sm" onComplete={completeSetup} />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (!isAuthenticated) {
|
|
return (
|
|
<div className="min-h-screen flex items-center justify-center bg-background p-4">
|
|
<Login className="w-full max-w-sm" />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<NodeProvider>
|
|
<EditorLayout />
|
|
</NodeProvider>
|
|
);
|
|
}
|
|
|
|
import { Toaster } from 'sonner';
|
|
|
|
function App() {
|
|
return (
|
|
<AuthProvider>
|
|
<AppContent />
|
|
<Toaster position="bottom-right" richColors />
|
|
</AuthProvider>
|
|
);
|
|
}
|
|
|
|
export default App;
|