import { Navigate, Routes, Route, useNavigate, useLocation } from 'react-router-dom' import Viewer from './viewer' import Gallery from './gallery' import Login from './account/login' import { getServerUrl } from './hooks/getConstants' import { useEffect } from 'react' import CreateRootUser from './account/createRoot' import { AccountProvider } from './contexts/useAccount' import { NotifierProvider } from './contexts/useNotifier' function RedirectHandler() { return (
) } function App() { const navigate = useNavigate() const location = useLocation() useEffect(() => { const checkRootUser = async () => { const response = await fetch(`${getServerUrl()}/api/user/rootUserExists`) const data = await response.json() if (data.exists) { // Only navigate to gallery if we're on the root path if (location.pathname === '/') { navigate('/gallery') } } else { // Always redirect to onboarding if root user doesn't exist if (location.pathname !== '/onboarding/createRootUser') { navigate('/onboarding/createRootUser') } } } checkRootUser() }, [location.pathname, navigate]) return ( } /> } /> } /> } /> } /> ) } export default App