This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
outline/frontend/components/Collection/Collection.js
2017-05-29 18:04:26 -07:00

49 lines
1.3 KiB
JavaScript

// @flow
import React from 'react';
import { observer } from 'mobx-react';
import { Link } from 'react-router-dom';
import moment from 'moment';
import styles from './Collection.scss';
@observer class Collection extends React.Component {
static propTypes = {
data: React.PropTypes.object.isRequired,
};
render() {
const data = this.props.data;
return (
<div className={styles.container}>
<h2>
<Link to={data.url} className={styles.atlasLink}>{data.name}</Link>
</h2>
{data.recentDocuments.length > 0
? data.recentDocuments.map(document => {
return (
<Link
key={document.id}
to={document.url}
className={styles.link}
>
<h3 className={styles.title}>{document.title}</h3>
<span className={styles.timestamp}>
{moment(document.updatedAt).fromNow()}
</span>
</Link>
);
})
: <div className={styles.description}>
No documents. Why not
{' '}
<Link to={`${data.url}/new`}>create one</Link>
?
</div>}
</div>
);
}
}
export default Collection;