Fixing trade to show the correct player.

logins
Thomas Hintz 5 years ago
parent 38c2920b85
commit fc3a49ce6b

@ -584,7 +584,7 @@ class TradeContainer2 extends React.Component {
prevProps.game.otherPlayers.length !== this.props.game.otherPlayers.length) {
this.setState({ otherPlayer: findPlayer(this.props.game,
this.props.game.otherPlayers.length > 0 ? this.props.game.otherPlayers[0].player.name : '') });
} else if (this.state.otherPlayer && this.state.otherPlayer !== findPlayer(this.props.game, this.state.otherPlayer.name)) {
} else if (this.state.otherPlayer && this.state.otherPlayer.name !== findPlayer(this.props.game, this.state.otherPlayer.name).name) {
this.setState({ otherPlayer: findPlayer(this.props.game, this.state.otherPlayer.name) });
}
if (prevProps.player.trade.originator && !this.props.player.trade.originator) {
@ -812,9 +812,13 @@ class TradeContainer2 extends React.Component {
{' '}
</Fragment>
))}
<select onChange={this.selectPlayer}>
<select onChange={this.selectPlayer}
value={otherPlayer.name}
defaultValue={otherPlayer.name}>
{this.props.game.otherPlayers.map(p => (
<option key={p.player.name} value={p.player.name}>{p.player.name}</option>
<option key={p.player.name} value={p.player.name}>
{p.player.name}
</option>
))}
</select>
</div>

Loading…
Cancel
Save