mirror of
https://github.com/openziti/zrok.git
synced 2025-01-21 21:38:50 +01:00
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
|
|
import Register from "./register/Register";
|
|
import Console from "./console/Console";
|
|
import {useEffect, useState} from "react";
|
|
import Login from "./console/login/Login";
|
|
import ResetPassword from "./resetPassword/ResetPassword"
|
|
|
|
const App = () => {
|
|
const [user, setUser] = useState();
|
|
|
|
useEffect(() => {
|
|
const localUser = localStorage.getItem("user");
|
|
if(localUser) {
|
|
setUser(JSON.parse(localUser));
|
|
console.log("reloaded user", localUser);
|
|
}
|
|
}, []);
|
|
|
|
const logout = () => {
|
|
setUser(null);
|
|
localStorage.clear();
|
|
}
|
|
|
|
const consoleComponent = user ? <Console logout={logout} user={user} /> : <Login loginSuccess={setUser} />
|
|
|
|
return (
|
|
<Router>
|
|
<Routes>
|
|
<Route path={"/"} element={consoleComponent}/>
|
|
<Route path={"register/:token"} element={<Register />} />
|
|
<Route path={"resetPassword"} element={<ResetPassword />}/>
|
|
<Route path={"resetPassword/:token"} element={<ResetPassword />}/>
|
|
</Routes>
|
|
</Router>
|
|
);
|
|
}
|
|
|
|
export default App; |