UNPKG

nexshop-web-contents

Version:

Nexshop Web Contents Project

44 lines (35 loc) 1.23 kB
import React, {Component} from 'react'; import {connect} from "react-redux"; import PropTypes from 'prop-types'; import ContentsPreviewHeaderView from "./contents-preview-header-view"; import ContentsPreviewDetailView from "./contents-preview-detail-view"; class ContentsPreview extends Component { constructor(props) { super(props); this.onClickClose = this.onClickClose.bind(this); } onClickClose() { this.props.history.goBack(); } render() { const {selectedId, contents} = this.props; const contentsItem = contents.find(contentsItem => contentsItem.id === selectedId); return ( <div> <ContentsPreviewHeaderView type={contentsItem.type} name={contentsItem.name} onClickClose={this.onClickClose}/> <ContentsPreviewDetailView contents={contentsItem} /> </div> ); } } const mapStateToProps = (state) => { const { contents: {selectedId, contents} } = state; return {selectedId, contents}; }; export default connect(mapStateToProps)(ContentsPreview); ContentsPreview.propTypes = { selectedId: PropTypes.string.isRequired, contents: PropTypes.array.isRequired, };