implemented logout and rename login module to auth

This commit is contained in:
Sebastian Sdorra
2018-07-12 11:33:41 +02:00
parent f9ebc26fef
commit e041dae964
8 changed files with 176 additions and 16 deletions

View File

@@ -1,15 +1,22 @@
//@flow
import React from "react";
import PrimaryNavigationLink from "./PrimaryNavigationLink";
import PrimaryNavigationAction from "./PrimaryNavigationAction";
type Props = {};
type Props = {
onLogout: () => void
};
class PrimaryNavigation extends React.Component<Props> {
render() {
return (
<nav className="tabs is-boxed">
<ul>
<PrimaryNavigationLink to="/users">Users</PrimaryNavigationLink>
<PrimaryNavigationLink to="/users" label="Users" />
<PrimaryNavigationAction
onClick={this.props.onLogout}
label="Logout"
/>
</ul>
</nav>
);

View File

@@ -0,0 +1,20 @@
//@flow
import * as React from "react";
type Props = {
label: string,
onClick: () => void
};
class PrimaryNavigationAction extends React.Component<Props> {
render() {
const { label, onClick } = this.props;
return (
<li>
<a onClick={onClick}>{label}</a>
</li>
);
}
}
export default PrimaryNavigationAction;

View File

@@ -4,16 +4,16 @@ import { Route, Link } from "react-router-dom";
type Props = {
to: string,
activeOnlyWhenExact?: boolean,
children?: React.Node
label: string,
activeOnlyWhenExact?: boolean
};
class PrimaryNavigationLink extends React.Component<Props> {
renderLink = (route: any) => {
const { to, children } = this.props;
const { to, label } = this.props;
return (
<li className={route.match ? "is-active" : ""}>
<Link to={to}>{children}</Link>
<Link to={to}>{label}</Link>
</li>
);
};