import React from 'react'; import { withRouter, Link } from 'react-router-dom'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; import Logout from './logout.jsx'; class CommonLinks extends React.Component { constructor(props) { super(props); this.state = { // } } render() { //render any extra stuff let Extra; if (this.props.extra) { Extra = this.props.extra; } else { Extra = () => null; } //if logged in if (this.props.loggedIn) { return (

Your Kingdom

Your Equipment

Attack (Game Ladder)

Combat Log

Change Password

Task List

Patron List

Rules

this.props.history.push('/') } />
); } else { //if not logged in return (

Sign Up

Login

Recover Password

Game Ladder

Task List

Patron List

Rules

); } } }; CommonLinks.propTypes = { loggedIn: PropTypes.bool.isRequired, onClickSignup: PropTypes.func, onClickLogin: PropTypes.func, onClickPasswordChange: PropTypes.func, onClickPasswordRecover: PropTypes.func, onClickProfile: PropTypes.func, onClickEquipment: PropTypes.func, onClickLadder: PropTypes.func, onClickCombatLog: PropTypes.func, onClickTaskList: PropTypes.func, onClickPatronList: PropTypes.func, onClickRules: PropTypes.func }; function mapStoreToProps(store) { return { loggedIn: store.account.id !== undefined && store.account.id !== 0 } }; function mapDispatchToProps(dispatch) { return { // } }; CommonLinks = connect(mapStoreToProps, mapDispatchToProps)(CommonLinks); export default withRouter(CommonLinks);