import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import dateFormat from 'dateFormat';
import { Card } from './UI';
import { statusDescriptions } from '../constants/publishModes';
import styles from './UnpublishedListing.css';
export default class UnpublishedListing extends React.Component {
renderColumns(entries, column) {
if (!entries) return;
if (!column) {
return entries.entrySeq().map(([currColumn, currEntries]) => (
{statusDescriptions.get(currColumn)}
{this.renderColumns(currEntries, currColumn)}
));
} else {
return
{entries.map(entry => {
// Look for an "author" field. Fallback to username on backend implementation;
const author = entry.getIn(['data', 'author'], entry.getIn(['metaData', 'user']));
const timeStamp = dateFormat(Date.parse(entry.getIn(['metaData', 'timeStamp'])), 'longDate');
return (
{entry.getIn(['data', 'title'])} by {author}
Last updated: {timeStamp} by {entry.getIn(['metaData', 'user'])}
);
}
)}
;
}
}
render() {
const columns = this.renderColumns(this.props.entries);
return (
{columns}
);
}
}
UnpublishedListing.propTypes = {
entries: ImmutablePropTypes.orderedMap,
};