Better individual scenes for documents

This commit is contained in:
Jori Lallo
2016-05-22 07:25:13 -07:00
parent 73e13e1849
commit b840b300b5
9 changed files with 50 additions and 7 deletions

View File

@@ -0,0 +1,59 @@
import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { fetchDocumentAsync } from 'actions/DocumentActions';
import Layout from 'components/Layout';
import AtlasPreviewLoading from 'components/AtlasPreviewLoading';
import CenteredContent from 'components/CenteredContent';
import Document from 'components/Document';
import styles from './DocumentScene.scss';
class DocumentScene extends React.Component {
componentDidMount = () => {
const documentId = this.props.routeParams.id;
this.props.fetchDocumentAsync(documentId);
}
render() {
const document = this.props.document;
let title;
if (document) {
title = `${document.atlas.name} - ${document.title}`;
}
return (
<Layout
title={ title }
>
<CenteredContent>
{ this.props.isLoading || !document ? (
<AtlasPreviewLoading />
) : (
<Document document={ document } />
) }
</CenteredContent>
</Layout>
);
}
};
const mapStateToProps = (state) => {
return {
isLoading: state.document.isLoading,
document: state.document.data,
}
};
const mapDispatchToProps = (dispatch) => {
return bindActionCreators({
fetchDocumentAsync,
}, dispatch)
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(DocumentScene);