diff --git a/common/utilities.js b/common/utilities.js index 0d898ee..1d2b474 100644 --- a/common/utilities.js +++ b/common/utilities.js @@ -10,7 +10,9 @@ let excluded = [ //messages that should not be logged 'Not enough soldiers', 'Not enough spies', 'Not enough scientists', - 'Not enough time has passed' + 'Not enough time has passed', + + 'Profile sent' ]; const log = (msg, ...args) => { diff --git a/server/profiles.js b/server/profiles.js index bdd66b7..ba8f6bc 100644 --- a/server/profiles.js +++ b/server/profiles.js @@ -98,7 +98,7 @@ function profileRequestInner(connection, req, res, fields) { scientists: results[0].scientists }); res.end(); -// log('Profile sent', fields.username, fields.id, fields.token); + log('Profile sent', fields.username, fields.id, fields.token); } }); } diff --git a/src/components/pages/home.jsx b/src/components/pages/home.jsx index 83fe21e..10128dc 100644 --- a/src/components/pages/home.jsx +++ b/src/components/pages/home.jsx @@ -4,18 +4,18 @@ import { withRouter, Link } from 'react-router-dom'; import PropTypes from 'prop-types'; //panels +import CommonLinks from '../panels/common_links.jsx'; + import Signup from '../panels/signup.jsx'; import Login from '../panels/login.jsx'; -import Logout from '../panels/logout.jsx'; -import PasswordChange from '../panels/password_change.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 = { - changedPassword: false, signupSent: false, signupMsg: '', recoverSent: false, @@ -34,14 +34,14 @@ class Home extends React.Component { SidePanel = this.LoggedOutSidePanel.bind(this); } - //TODO: news column - //return the home page return (

KINGDOM BATTLES!

+
+

News

@@ -62,35 +62,15 @@ class Home extends React.Component { this.setState({ recoverSent: false }); } - //build the password change panel - let PasswordChangePanel; - - if (!this.state.changedPassword) { - PasswordChangePanel = () => { - return ( { this.setState({changedPassword: true}) }} />); - } - } else { - PasswordChangePanel = () => { - return (

Password changed!

); - } - } - //finally return the side panel return (
-

Go to your profile

- - +
); } LoggedOutSidePanel() { - //reset the other mode - if (this.state.changedPassword) { - this.setState({ changedPassword: false }); - } - //build the signup panel let SignupPanel; diff --git a/src/components/pages/profile.jsx b/src/components/pages/profile.jsx index e0fb1bd..fcba12d 100644 --- a/src/components/pages/profile.jsx +++ b/src/components/pages/profile.jsx @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'; import queryString from 'query-string'; //panels -import Logout from '../panels/logout.jsx'; +import CommonLinks from '../panels/common_links.jsx'; import PasswordChange from '../panels/password_change.jsx'; class Profile extends React.Component { @@ -21,9 +21,7 @@ class Profile extends React.Component { scientists: 0, warning: '' }; - } - componentWillMount() { this.sendRequest('/profilerequest', this.state.params.username ? this.state.params.username : this.props.username); } @@ -65,6 +63,7 @@ class Profile extends React.Component {
+

{this.state.warning}

@@ -143,9 +142,7 @@ class Profile extends React.Component { //finally return the side panel return (
-

Return home

- - this.props.history.push('/')} /> + } />
); } @@ -200,9 +197,7 @@ class Profile extends React.Component { //finally return the side panel return (
-

Return home

-

Go to { e.preventDefault(); this.sendRequest('/profilerequest', this.props.username); this.setWarning(''); this.props.history.push('/profile'); }}>your profile

- this.props.history.push('/')} /> + {e.preventDefault(); this.sendRequest('/profilerequest', this.props.username); this.setWarning(''); this.props.history.push('/profile');}} />
); } @@ -258,7 +253,7 @@ class Profile extends React.Component { LoggedOutSidePanel() { return (
-

Return home

+
); } diff --git a/src/components/panels/common_links.jsx b/src/components/panels/common_links.jsx new file mode 100644 index 0000000..eb3b474 --- /dev/null +++ b/src/components/panels/common_links.jsx @@ -0,0 +1,37 @@ +import React from 'react'; +import { withRouter, Link } from 'react-router-dom'; + +import Logout from './logout.jsx'; + +class CommonLinks extends React.Component { + constructor(props) { + super(props); + this.state = { + // + } + } + + render() { + let Extra; + + if (this.props.extra) { + Extra = this.props.extra; + } else { + Extra = () => null; + } + + return ( +
+

Return home

+

Go to your profile

+

Go to the game ladder

+ + + + this.props.history.push('/')} /> +
+ ); + } +} + +export default withRouter(CommonLinks); \ No newline at end of file