import { h } from "preact"; import { Router, route } from "preact-router"; import {Header, Menu} from "./"; import { menuReducer, sessionReducer } from "../store/reducers"; import { useReducer } from "preact/hooks"; import { Home, Users, Profile, Login, Logout } from "../route"; import { AppStateProvider } from "../store/AppState"; function App() { // useReducer const menu = useReducer(menuReducer, false); const session = useReducer(sessionReducer, {active: true}); this.menu_items = [ { text: "Übersicht", path: "/" }, { text: "Benutzer", path: "/users" }, { text: "System", path: "/system" }, { text: "Profil", path: "/profile" }, { text: "Abmelden", path: "/logout" } ] this.handleRoute = async e => { switch (e.url) { default: if (!session[0].active) route('/login', true); break; } }; return (
{!menu[0] &&
Error 404
}
); } export default App;