Simplified CommonLinks
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
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';
|
||||
|
||||
@@ -21,38 +22,46 @@ class CommonLinks extends React.Component {
|
||||
Extra = () => null;
|
||||
}
|
||||
|
||||
//disable the profile link when logged out
|
||||
let ProfileLink;
|
||||
//if logged in
|
||||
if (this.props.loggedIn) {
|
||||
ProfileLink = () => <p><Link to='/profile' onClick={this.props.onClickProfile}>Your Profile</Link></p>;
|
||||
} else {
|
||||
ProfileLink = () => null;
|
||||
return (
|
||||
<div className='panel'>
|
||||
<p><Link to='/' onClick={this.props.onClickHome}>Return Home</Link></p>
|
||||
<p><Link to='/profile' onClick={this.props.onClickProfile}>Your Profile</Link></p>
|
||||
<p><Link to='/ladder' onClick={this.props.onClickLadder}>Game Ladder</Link></p>
|
||||
<p><Link to='/passwordchange' onClick={this.props.onClickPasswordChange}>Change Password</Link></p>
|
||||
|
||||
<Extra />
|
||||
|
||||
<Logout onClick={() => this.props.history.push('/')} />
|
||||
</div>
|
||||
);
|
||||
} else { //if not logged in
|
||||
return (
|
||||
<div className='panel'>
|
||||
<p><Link to='/signup' onClick={this.props.onClickSignup}>Sign Up</Link></p>
|
||||
<p><Link to='/login' onClick={this.props.onClickLogin}>Login</Link></p>
|
||||
<p><Link to='/passwordrecover' onClick={this.props.onClickPasswordRecover}>Recover Password</Link></p>
|
||||
<p><Link to='/' onClick={this.props.onClickHome}>Return Home</Link></p>
|
||||
<p><Link to='/ladder' onClick={this.props.onClickLadder}>Game Ladder</Link></p>
|
||||
|
||||
<Extra />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
//disable the logout button when logged out
|
||||
let LogoutLink;
|
||||
if (this.props.loggedIn) {
|
||||
LogoutLink = () => <Logout onClick={() => this.props.history.push('/')} />;
|
||||
} else {
|
||||
LogoutLink = () => null;
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<div className='panel'>
|
||||
<p><Link to='/' onClick={this.props.onClickHome}>Return Home</Link></p>
|
||||
<ProfileLink />
|
||||
<p><Link to='/ladder' onClick={this.props.onClickLadder}>Game Ladder</Link></p>
|
||||
<p><Link to='/passwordchange' onClick={this.props.onClickLadder}>Change Password</Link></p>
|
||||
|
||||
<Extra />
|
||||
|
||||
<LogoutLink />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
CommonLinks.propTypes = {
|
||||
onClickSignup: PropTypes.func,
|
||||
onClickLogin: PropTypes.func,
|
||||
onClickPasswordRecover: PropTypes.func,
|
||||
onClickHome: PropTypes.func,
|
||||
onClickProfile: PropTypes.func,
|
||||
onClickLadder: PropTypes.func,
|
||||
onClickPasswordChange: PropTypes.func
|
||||
};
|
||||
|
||||
function mapStoreToProps(store) {
|
||||
return {
|
||||
loggedIn: store.account.id !== 0
|
||||
|
||||
@@ -15,7 +15,7 @@ class NewsPanel extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
{Object.keys(this.state.data).map((key) => <div key={key}><ReactMarkdown source={this.state.data[key]} escapeHTML={false} /><hr /></div> )}
|
||||
{Object.keys(this.state.data).map((key) => <div key={key}><ReactMarkdown source={this.state.data[key]} escapeHTML={false} /><hr className='newsLine' /></div> )}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user