components/Common/Table.jsx

/**
 * Модуль таблицы
 * @module Table
 * @author Ihor Bielchenko
 * @requires react
 * @requires react#Component
 */

import React, { Component } from 'react';

/**
 * Таблица
 * @extends Component
 * @property {Array} columns Массив столбцов
 * @property {Array} data Массив данных таблицы
 */
class Table extends Component {

	/**
	 * Render component
	 * @return {Object} jsx object
	 */
	render() {
		var columns = [],
			lines = [],
			data, i, o, k;

		for(i = 0; i < this.props.columns.length; i++) {
			columns.push(<div key={i}
							className="c">{this.props.columns[i]}</div>)
		}

		k = 0;
		for(i = 0; i < this.props.data.length; i++) {
			o = '';
			data = [];

			for(o in this.props.data[i]) {
				data.push(<div key={k}
					className="c">{this.props.data[i][o]}</div>);
				k++;
			}

			lines.push(<div key={i}
				className="line">{data}</div>);
		}

		return <div className="teacher-table">
					<div className="wrap">
						<div className="content">
							<div className="line topline">
								{columns}
							</div>

							{lines}
						</div>
					</div>
				</div>
	}
}

export default Table;