Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
App.tsx 1.35 KiB
import "./App.css";
import Home from "./pages/Home";
import Garten from "./pages/Garten";
import Suche from "./pages/Suche";
import {Routes, Route} from "react-router-dom";
import Wunschliste from "./pages/Wunschliste";
import PlantDetails from "./components/PlantDetails";
import Navbar from "./components/Navbar.tsx";
import NavbarRegistrationAndLogin from "./components/NavbarRegistrationAndLogin.tsx";
import {useState} from "react";
import {checkJwtStatus, deleteJwtCookie} from "./jwt/Cookies.ts";
import Login from "./pages/Login.tsx";
import Register from "./pages/Register.tsx";

function App() {
  const [isLoggedIn, setIsLoggedIn] = useState(false);

  checkJwtStatus(setIsLoggedIn);

  const handleLogout = async () => {
    deleteJwtCookie();
    setIsLoggedIn(false);
  };

  return (
    <div className="App">
      {isLoggedIn ? <Navbar onLogout={handleLogout} /> : <NavbarRegistrationAndLogin />}
      <Routes>
        <Route path="/" element={<Home />} />
        <Route path="/garten" element={<Garten />} />
        <Route path="/wunschliste" element={<Wunschliste />} />
        <Route path="/suchen" element={<Suche />} />
        <Route path="/pflanze/:plantId" element={<PlantDetails />} />
        <Route path="/register" element={<Register />} />
        <Route path="/login" element={<Login />} />
      </Routes>

    </div>
  );
}

export default App;