Started equipment; need to rework state system

This commit is contained in:
2019-05-31 02:12:35 +10:00
parent dd3f18f7d1
commit b97d8fc184
8 changed files with 210 additions and 21 deletions
+18 -1
View File
@@ -7,6 +7,7 @@ import queryString from 'query-string';
//panels
import CommonLinks from '../panels/common_links.jsx';
import AttackButton from '../panels/attack_button.jsx';
import Equipment from '../panels/equipment.jsx';
import CombatLog from '../panels/combat_log.jsx';
class Profile extends React.Component {
@@ -27,12 +28,24 @@ class Profile extends React.Component {
warning: '',
start: params.log
//combat log
start: params.log,
//equipment
fetchStatistics: null,
fetchEquipment: null
};
this.sendRequest('/profilerequest', this.state.params.username ? this.state.params.username : this.props.username);
}
componentDidUpdate(prevProps, prevState, snapshot) {
if (JSON.stringify(this.state) !== JSON.stringify(prevState)) {
// if (this.state.fetchStatistics) this.state.fetchStatistics();
// if (this.state.fetchEquipment) this.state.fetchEquipment();
}
}
render() {
let warningStyle = {
display: this.state.warning.length > 0 ? 'flex' : 'none'
@@ -197,6 +210,10 @@ class Profile extends React.Component {
</div>
</div>
<br />
<h1 className='centered'>Equipment</h1>
<Equipment username={this.props.username} token={this.props.token} scientists={1} getFetchSattistics={ (fn) => this.setState({ fetchStatistics: fn }) } getFetchEquipment={ (fn) => this.setState({ fetchEquipment: fn}) } />
<br />
<h1 className='centered'>Combat Log</h1>
<CombatLog username={this.props.username} start={this.state.start} length={this.state.length} />