Broke up the home page
This commit is contained in:
@@ -4,21 +4,13 @@ import { withRouter, Link } from 'react-router-dom';
|
||||
|
||||
//panels
|
||||
import CommonLinks from '../panels/common_links.jsx';
|
||||
|
||||
import Signup from '../panels/signup.jsx';
|
||||
import Login from '../panels/login.jsx';
|
||||
import PasswordRecover from '../panels/password_recover.jsx';
|
||||
|
||||
import NewsPanel from '../panels/news_panel.jsx';
|
||||
|
||||
class Home extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
signupSent: false,
|
||||
signupMsg: '',
|
||||
recoverSent: false,
|
||||
recoverMsg: ''
|
||||
//
|
||||
};
|
||||
}
|
||||
|
||||
@@ -27,10 +19,24 @@ class Home extends React.Component {
|
||||
//get the correct side panel
|
||||
let SidePanel;
|
||||
|
||||
if (this.props.id) {
|
||||
SidePanel = this.LoggedInSidePanel.bind(this);
|
||||
} else {
|
||||
SidePanel = this.LoggedOutSidePanel.bind(this);
|
||||
if (this.props.id) { //logged in
|
||||
SidePanel = () => {
|
||||
return (
|
||||
<div className='sidePanel'>
|
||||
<CommonLinks />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
} else { //logged out
|
||||
SidePanel = () => {
|
||||
return (
|
||||
<div className='sidePanel'>
|
||||
<p><Link to='/signup'>Sign Up</Link></p>
|
||||
<p><Link to='/login'>Login</Link></p>
|
||||
<p><Link to='/passwordrecover'>Recover Password</Link></p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//return the home page
|
||||
@@ -47,77 +53,11 @@ class Home extends React.Component {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
//panel functions
|
||||
LoggedInSidePanel() {
|
||||
//reset the other mode
|
||||
if (this.state.signupSent) {
|
||||
this.setState({ signupSent: false });
|
||||
}
|
||||
|
||||
if (this.state.recoverSent) {
|
||||
this.setState({ recoverSent: false });
|
||||
}
|
||||
|
||||
//finally return the side panel
|
||||
return (
|
||||
<div className='sidePanel'>
|
||||
<CommonLinks />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
LoggedOutSidePanel() {
|
||||
//build the signup panel
|
||||
let SignupPanel;
|
||||
|
||||
if (!this.state.signupSent) {
|
||||
SignupPanel = () => {
|
||||
return (
|
||||
<Signup onSignup={(msg) => this.setState( {signupSent: true, signupMsg: msg} )} />
|
||||
);
|
||||
}
|
||||
} else {
|
||||
SignupPanel = () => {
|
||||
return (
|
||||
<p>{this.state.signupMsg}</p>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//build the recover panel
|
||||
let RecoverPanel;
|
||||
|
||||
if (!this.state.recoverSent) {
|
||||
RecoverPanel = () => {
|
||||
return (
|
||||
<PasswordRecover onEmailSent={(msg) => this.setState( {recoverSent: true, recoverMsg: msg} )} />
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
RecoverPanel = () => {
|
||||
return (
|
||||
<p>{this.state.recoverMsg}</p>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//finally return the side panel
|
||||
return (
|
||||
<div className='sidePanel'>
|
||||
<SignupPanel />
|
||||
<Login onSubmit={() => {this.props.history.push('/profile');}} />
|
||||
<RecoverPanel />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function mapStoreToProps(store) {
|
||||
return {
|
||||
id: store.account.id,
|
||||
token: store.account.token
|
||||
id: store.account.id
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user