mirror of
https://github.com/containrrr/watchtower.git
synced 2026-02-26 08:54:08 +01:00
Use Vite build tool
This commit is contained in:
parent
57b4862a5b
commit
5645cd23fe
40 changed files with 3513 additions and 2715 deletions
47
web/src/App.tsx
Normal file
47
web/src/App.tsx
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import { useEffect, useState } from "react"
|
||||
import ContainerView from "./components/ContainerView";
|
||||
import Header from "./components/Header";
|
||||
import Login from "./components/Login";
|
||||
import Spinner from "./components/Spinner";
|
||||
import { checkLogin, logOut } from "./services/Api";
|
||||
|
||||
const App = () => {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [loggedIn, setLoggedIn] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
(async () => {
|
||||
setLoggedIn(await checkLogin());
|
||||
setLoading(false);
|
||||
})();
|
||||
}, []);
|
||||
|
||||
const onLogIn = () => {
|
||||
setLoading(false);
|
||||
setLoggedIn(true);
|
||||
}
|
||||
|
||||
const onLogOut = () => {
|
||||
logOut();
|
||||
setLoading(false);
|
||||
setLoggedIn(false);
|
||||
};
|
||||
|
||||
if (loading === true) {
|
||||
return <div className="mt-5 pt-5"><Spinner /></div>;
|
||||
}
|
||||
|
||||
if (loggedIn !== true) {
|
||||
return <Login onLogin={onLogIn} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Header onLogOut={onLogOut} />
|
||||
<ContainerView />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default App
|
||||
Loading…
Add table
Add a link
Reference in a new issue