84 lines
2.0 KiB
JavaScript
84 lines
2.0 KiB
JavaScript
var Player = React.createClass({
|
|
propTypes: {
|
|
email: React.PropTypes.string,
|
|
id: React.PropTypes.number
|
|
},
|
|
|
|
//getInitialState: function() {
|
|
//return {
|
|
//id: this.props.id
|
|
//email: ""
|
|
//};
|
|
//},
|
|
|
|
// componentDidMount: function() {
|
|
// $.get(this.props.source, function(result) {
|
|
// if (this.isMounted()) {
|
|
// console.log("Mounted from player");
|
|
// //this.setState({
|
|
// //id: result.id
|
|
// //email: result.email
|
|
// //});
|
|
// console.log(result.id);
|
|
// this.setProps({
|
|
// id: result.id
|
|
// });
|
|
// }
|
|
// }.bind(this));
|
|
// },
|
|
|
|
render: function() {
|
|
return (
|
|
<div>
|
|
<div>Id: {this.props.id}</div>
|
|
<div>Email: {this.props.email}</div>
|
|
<div>Inventory count: {this.props.inventory_count}</div>
|
|
<div><Inventory cards={this.props.inventory} player_id={this.props.id} /></div>
|
|
<div><PlayerControls key={this.props.id} game_id={this.props.game_id} player_id={this.props.id} /></div>
|
|
</div>
|
|
);
|
|
}
|
|
});
|
|
|
|
|
|
var PlayerList = React.createClass({
|
|
// propTypes: {
|
|
// players: React.PropTypes.array
|
|
// },
|
|
|
|
// getInitialState: function() {
|
|
// return {
|
|
// players: []
|
|
// };
|
|
// },
|
|
|
|
// componentDidMount: function() {
|
|
// $.get(this.props.source, function(result) {
|
|
// if (this.isMounted()) {
|
|
// this.setState({
|
|
// players: result.players
|
|
// });
|
|
// console.log("Mounted from playerList");
|
|
// }
|
|
// }.bind(this));
|
|
// },
|
|
|
|
render: function() {
|
|
var playerList = this;
|
|
var playerNodes = this.props.players.map(function (player) {
|
|
return (
|
|
<Player key={player.id} game_id={playerList.props.game_id} {...player} />
|
|
);
|
|
});
|
|
//<Player key={player.id} id={player.id} email={player.email} inventory_count={player.inventory_count} inventory={player.inventory} />
|
|
|
|
return (
|
|
<div>
|
|
PlayerList:
|
|
{playerNodes}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
});
|