'use strict';

const React = require('react');
const moment = require('moment');

class Home extends React.Component {
    render() {
        return (
            <table>
                <tr>
                    <th>Date</th>
                    <th>ID</th>
                    <th>Shoot ID / Entry ID</th>
                    <th>Site</th>
                    <th>Title</th>
                    <th>Actors</th>
                </tr>

                {this.props.releases.map(release => (
                    <tr key={release.id}>
                        <td>{ moment(release.date).format('YYYY-MM-DD') }</td>
                        <td>{ release.id }</td>
                        <td>{ release.shootId || release.entryId }</td>
                        <td>{ release.site.name }</td>
                        <td>{ release.title }</td>
                        <td>{ release.actors && release.actors.map(actor => actor.name).join(', ') }</td>
                    </tr>
                ))}
            </table>
        );
    }
}

module.exports = Home;
