{"size": 1322, "ext": "js", "max_stars_repo_path": "js/components/admin_season_table.js", "max_stars_repo_name": "derikson/bodger-bowl", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "js/components/admin_season_table.js", "max_issues_repo_name": "derikson/bodger-bowl", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "js/components/admin_season_table.js", "max_forks_repo_name": "derikson/bodger-bowl", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.0363636364, "max_line_length": 113, "alphanum_fraction": 0.5960665658}
/* @flow */
var React = require('react');

var AdminSeasonRow = React.createClass({
	render: function() {
		var hrefTarget = "/admin/seasons/" + encodeURIComponent(this.props.season.Name + ";" + this.props.season.Year);
		return (
			<tr>
				<td><a href={hrefTarget}>{this.props.season.Name}</a></td>
				<td><a href={hrefTarget}>{this.props.season.Year}</a></td>
				<td><a href={hrefTarget}>{this.props.season.Active ? 'True' : 'False'}</a></td>
			</tr>
		);
	}
});

module.exports = React.createClass({
	loadSeasonsFromServer: function() {
		$.ajax({url:"/api/seasons/",
				type: 'GET',
				dataType: 'json',
				success: function(data) {
					this.setState({seasons: data});
				}.bind(this),
				error: function(xhr, status, err) {
					console.error(this.props.url, status, err.toString());
				}.bind(this)
		});
	},
	getInitialState: function(): {seasons: Array<Object>} {
		return {seasons: []};
	},
	componentDidMount: function() {
		this.loadSeasonsFromServer();
	},
	render: function(): ?ReactElement {
		var rows = [];
		this.state.seasons.forEach(function(season) {
			rows.push(<AdminSeasonRow season={season} />);
		});
		return (
			<div>
				<table>
					<thead>
						<th>Name</th>
						<th>Year</th>
						<th>Active</th>
					</thead>
					<tbody>{rows}</tbody>
				</table>
			</div>
		);
	}
});
