Equipment buying and selling complete

This commit is contained in:
2019-06-01 23:02:08 +10:00
parent 7c7e69d4c5
commit 8161ebb512
8 changed files with 294 additions and 72 deletions
+2
View File
@@ -54,6 +54,8 @@ class CombatLog extends React.Component {
<p>{this.state.warning}</p>
</div>
<h1 className='centered'>Combat Log</h1>
<ButtonHeader />
<PagedCombatLog
setWarning={this.setWarning.bind(this)}
+5
View File
@@ -55,11 +55,16 @@ class Equipment extends React.Component {
<p>{this.state.warning}</p>
</div>
<h1 className='centered'>Equipment</h1>
<p className='centered'>Equipment sells for half it's cost!</p>
<p className='centered'>Scientists: {this.props.scientists} - Gold: {this.props.gold}</p>
<EquipmentPanel
getFetch={this.getFetch.bind(this)}
setWarning={this.setWarning.bind(this)}
scientists={this.props.scientists}
gold={this.props.gold}
onSuccess={ () => this.sendRequest('/profilerequest', {username: this.props.username}) }
/>
</div>
</div>
+9 -4
View File
@@ -46,8 +46,8 @@ class Equipment extends React.Component {
<p className='col centered truncate'>{display[key].type}</p>
<p className='col centered truncate'>{display[key].owned}</p>
<p className='col centered truncate'>{display[key].cost}</p>
{display[key].purchasable ? <button className='col centered truncate' disabled={true || display[key].cost > this.props.gold}>+ Buy +</button> : <div className='col centered truncate' />}
{display[key].saleable ? <button className='col centered truncate' disabled={true || display[key].owned === 0}>- Sell -</button> : <div className='col centered truncate' />}
{display[key].purchasable ? <button className='col centered truncate' onClick={() => this.sendRequest('/equipmentpurchaserequest', { name: display[key].name, type: display[key].type }) } disabled={display[key].cost > this.props.gold}>+ Buy +</button> : <div className='col centered truncate' />}
{display[key].saleable ? <button className='col centered truncate' onClick={() => this.sendRequest('/equipmentsellrequest', { name: display[key].name, type: display[key].type }) } disabled={display[key].owned === 0}>- Sell -</button> : <div className='col centered truncate' />}
</div>)}
</div>
</div>
@@ -67,9 +67,13 @@ class Equipment extends React.Component {
//on success
this.setState(json);
if (this.props.onSuccess) {
this.props.onSuccess(json);
}
}
else if (xhr.status === 400 && this.props.setWarning) {
this.setWarning(xhr.responseText);
this.props.setWarning(xhr.responseText);
}
}
};
@@ -121,7 +125,8 @@ Equipment.propTypes = {
token: PropTypes.number.isRequired,
setWarning: PropTypes.func,
getFetch: PropTypes.func
getFetch: PropTypes.func,
onSuccess: PropTypes.func
};
const mapStoreToProps = (store) => {