The main server, and probably only repository in this org.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.4 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. import React, {useEffect, useState} from 'react';
  2. import './App.css';
  3. import Header from "./Components/Structure/Header";
  4. import LoginForm from "./Components/Forms/LoginForm";
  5. import {Container} from "reactstrap";
  6. import {BrowserRouter} from "react-router-dom";
  7. import {Route} from "react-router";
  8. import useAuth from "./Hooks/auth";
  9. import IndexPage from "./Components/Pages/IndexPage";
  10. import GroupPage from "./Components/Pages/GroupPage";
  11. import Loading from "./Components/Loading";
  12. import LightPage from "./Components/Pages/LightPage";
  13. import AdminPage from "./Components/Pages/AdminPage";
  14. export default function App() {
  15. const [hasStarted, setHasStarted] = useState(false);
  16. const {isLoggedIn, isChecked, verify} = useAuth();
  17. useEffect(() => {
  18. if (!hasStarted) {
  19. verify();
  20. setHasStarted(true);
  21. }
  22. });
  23. return (
  24. <BrowserRouter>
  25. <>
  26. <Header/>
  27. <Container>
  28. {!isChecked && <Loading/>}
  29. {isChecked && !isLoggedIn && <LoginForm/>}
  30. {isChecked && isLoggedIn && (
  31. <>
  32. <Route exact path="/" component={IndexPage}/>
  33. <Route exact path="/lights" component={LightPage}/>
  34. <Route exact path="/groups" component={GroupPage}/>
  35. <Route exact path="/admin" component={AdminPage}/>
  36. </>
  37. )}
  38. </Container>
  39. </>
  40. </BrowserRouter>
  41. );
  42. }