import React, { Component } from 'react';

import MessagePanel from './MessagePanel.js';



require('./Table.scss');

//FIXME i18n

class Table extends Component {


	constructor(props, context) {
		super(props, context);

		this.renderEmptyContent = this.renderEmptyContent.bind(this);
		this.renderItem = this.renderItem.bind(this);
	}


	renderItem(item, index) {
		return <div key={ index }></div>
	}


	renderEmptyContent() {
		return <MessagePanel title="Empty dataset" text="There is nothing to display" />;
	}


	render() {
		const { items, status } = this.props;

		if (status === "success" && (!Array.isArray(items) || !items.length)) {
			return (
				<div>
					{ this.renderEmptyContent() }
					<div className="clearfix"/>
				</div>
			);
		}

		let rows = [];
		for (let i = 0; items && i < items.length; i++) {
			rows.push(this.renderItem(items[i], i));
		}

		return (
			<div className={ `table ${this.props.className|| ""}` }>
				{ rows }	
			</div>
		);
	}

}


export default Table;