69 lines
1.6 KiB
JavaScript
69 lines
1.6 KiB
JavaScript
var Seat = React.createClass({
|
|
|
|
isOccupied: function() {
|
|
//TODO: create isOccupied logic
|
|
return false;
|
|
},
|
|
|
|
url: function() {
|
|
var url = "/seats/" + this.props.id + ".json"
|
|
return url;
|
|
},
|
|
|
|
sitClick: function(e) {
|
|
this.props.onSeatSubmit(this.props.id, 'sit');
|
|
},
|
|
|
|
standClick: function(e) {
|
|
this.props.onSeatSubmit(this.props.id, 'stand');
|
|
},
|
|
|
|
isAvailable: function() {
|
|
return this.props.user_display_name == null
|
|
},
|
|
|
|
sitButtonStyle: function() {
|
|
var style = {};
|
|
if(null != this.props.user_id == this.props.current_user.id)
|
|
style = { display: 'none'};
|
|
if(this.props.user_soft_token == this.props.current_user.soft_token)
|
|
style = { display: 'none'};
|
|
return style;
|
|
},
|
|
|
|
standButtonStyle: function() {
|
|
var style = { display: 'none'};
|
|
if(null != this.props.user_id == this.props.current_user.id)
|
|
style = {};
|
|
if(this.props.user_soft_token == this.props.current_user.soft_token)
|
|
style = {};
|
|
return style;
|
|
},
|
|
|
|
render: function() {
|
|
return (
|
|
<div className='seat'>
|
|
<div className='seat-controls'>
|
|
<button
|
|
onClick={this.sitClick}
|
|
style={ this.sitButtonStyle() }
|
|
disabled={!this.isAvailable()} >
|
|
Sit
|
|
</button>
|
|
<button
|
|
onClick={this.standClick}
|
|
style={ this.standButtonStyle() }>
|
|
Stand
|
|
</button>
|
|
</div>
|
|
{this.props.player ?
|
|
<Player
|
|
game={this.props.game}
|
|
onPlayHandSubmit={this.props.onPlayHandSubmit}
|
|
{...this.props.player} />
|
|
: "Empty" }
|
|
</div>
|
|
);
|
|
}
|
|
});
|