props.menu.toggle()}>
diff --git a/src/components/index.js b/src/components/index.js
new file mode 100644
index 0000000..6eb97cc
--- /dev/null
+++ b/src/components/index.js
@@ -0,0 +1,9 @@
+import App from "./app";
+import Breadcrumbs from "./breadcrumbs";
+import Pageselector from "./Pageselector";
+import Header from "./header";
+import UserList from "./userlist";
+import Menu from "./menu";
+
+export {App, Breadcrumbs, Pageselector, Header, UserList, Menu}
+export default App
\ No newline at end of file
diff --git a/src/components/menu/index.jsx b/src/components/menu/index.jsx
index db415de..ac4135a 100644
--- a/src/components/menu/index.jsx
+++ b/src/components/menu/index.jsx
@@ -17,13 +17,14 @@ class Menu extends Component {
e.preventDefault();
this.props.menu.toggle();
}
- render(props, state) {
+ render(props) {
+ if(props.items)
+ this.menu_items = props.items;
if (props.menu.visible)
return (
diff --git a/src/index.js b/src/index.js
index 3ff9b5d..fa27f13 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,5 +1,5 @@
import './style/style.sass';
-import App from './components/app';
+import App from './components';
import { h, render } from "preact"
render(, document.body)
diff --git a/src/routes/home/index.js b/src/route/home/index.js
similarity index 58%
rename from src/routes/home/index.js
rename to src/route/home/index.js
index 28777fc..b42343f 100644
--- a/src/routes/home/index.js
+++ b/src/route/home/index.js
@@ -1,11 +1,10 @@
import { h } from 'preact';
-import style from './style.css';
-const Home = () => (
-
+function Home() {return(
+
Home
This is the Home component.
);
-
+}
export default Home;
diff --git a/src/route/index.js b/src/route/index.js
new file mode 100644
index 0000000..a3f6098
--- /dev/null
+++ b/src/route/index.js
@@ -0,0 +1,6 @@
+import Home from "./home"
+import Users from './users'
+import Profile from "./profile"
+import Login from "./login"
+import Logout from './logout'
+export {Home, Users, Profile, Login, Logout }
\ No newline at end of file
diff --git a/src/routes/login/index.jsx b/src/route/login/index.jsx
similarity index 57%
rename from src/routes/login/index.jsx
rename to src/route/login/index.jsx
index 51f2a3e..5876282 100644
--- a/src/routes/login/index.jsx
+++ b/src/route/login/index.jsx
@@ -1,40 +1,48 @@
import { h } from 'preact';
import { useState } from 'preact/hooks';
+import { route } from 'preact-router';
import Breadcrumbs from '../../components/breadcrumbs';
-const Login = (props,ctx) => {
- const [val,set] = useState({ username: '', password: '' });
+function Login(props, ctx) {
+ const [val, set] = useState({ username: '', password: '', error: null });
const navigation = ["Login"];
const session = ctx.get('Session');
- function onSubmit (e) {
+ function onSubmit(e) {
e.preventDefault();
- session.data = val;
- console.log(session.data);
- set({username: '', password: '' });
+ //sucess
+ if (val.username === 'admin') {
+ session.data = val;
+ route('/', true);
+ }
+ else {
+ set({ ...val, error: "user" });
+ }
+ set({ username: '', password: '' });
}
-
- return (
+ return (
-
);
+ );
}
diff --git a/src/route/logout/index.jsx b/src/route/logout/index.jsx
new file mode 100644
index 0000000..2becf48
--- /dev/null
+++ b/src/route/logout/index.jsx
@@ -0,0 +1,30 @@
+import { h } from 'preact';
+import { Link } from 'preact-router';
+
+import { Breadcrumbs } from '../../components';
+
+function Logout (props, ctx) {
+ const navigation = ["Logout"];
+ const session = ctx.get('Session');
+ this.shouldComponentUpdate = function(){
+ console.log('functional component vs closures');
+ }
+ if (session.actions.isAuth()) {
+ session.data = { username: '', password: '' };
+
+ }
+
+ return (
+
+
+
+
+ Erfolgreich abgemeldet.
+ Erneut Anmelden
+
+
+ );
+
+}
+
+export default Logout;
\ No newline at end of file
diff --git a/src/routes/profile/index.js b/src/route/profile/index.js
similarity index 50%
rename from src/routes/profile/index.js
rename to src/route/profile/index.js
index 84a57e0..e1564a9 100644
--- a/src/routes/profile/index.js
+++ b/src/route/profile/index.js
@@ -1,5 +1,5 @@
import { h } from 'preact';
-import {useEffect, useState} from "preact/hooks";
+import { useEffect, useState } from "preact/hooks";
import style from './style.css';
// Note: `user` comes from the URL, courtesy of our router
@@ -13,17 +13,19 @@ const Profile = ({ user }) => {
}, []);
return (
-
-
Profile: {user}
-
This is the user profile for a user named { user }.