login/logout logic, breadcrumbs, initial ui stuff

This commit is contained in:
wisplite
2025-11-19 15:38:21 -06:00
parent ccf644acef
commit d176d6d761
23 changed files with 1359 additions and 36 deletions
+45 -9
View File
@@ -1,16 +1,52 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
function App() {
const [count, setCount] = useState(0)
import { Navigate, Routes, Route, useNavigate, useLocation } from 'react-router-dom'
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 (
<div>
<h1>Raster</h1>
<p className="text-red-500">Hello World</p>
<div className="flex flex-col items-center justify-center h-full w-full bg-[#141414]">
</div>
)
}
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 (
<NotifierProvider>
<AccountProvider>
<Routes>
<Route path="/" element={<RedirectHandler />} />
<Route path="/gallery/*" element={<Gallery />} />
<Route path="/login" element={<Login />} />
<Route path="/onboarding/createRootUser" element={<CreateRootUser />} />
</Routes>
</AccountProvider>
</NotifierProvider>
)
}
export default App