import React from 'react'; import PropTypes from 'prop-types'; import { Helmet } from 'react-helmet'; import brand from 'ba-api/brand'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import data from 'ba-api/timelineData'; import { fetchAction, postAction, toggleLikeAction, fetchCommentAction, postCommentAction, closeNotifAction } from 'ba-actions/SocmedActions'; import { Timeline, WritePost, SideSection, Notification } from 'ba-components'; import { Grid } from '@material-ui/core'; class SocialMedia extends React.Component { componentDidMount() { this.props.fetchData(data); } render() { const title = brand.name + ' - Social Media'; const description = brand.desc; const { dataProps, submitPost, submitLike, submitComment, fetchComment, commentIndex, closeNotif, messageNotif, } = this.props; return (
{title} closeNotif()} message={messageNotif} />
); } } SocialMedia.propTypes = { fetchData: PropTypes.func.isRequired, submitPost: PropTypes.func.isRequired, submitLike: PropTypes.func.isRequired, submitComment: PropTypes.func.isRequired, dataProps: PropTypes.object.isRequired, fetchComment: PropTypes.func.isRequired, commentIndex: PropTypes.number.isRequired, closeNotif: PropTypes.func.isRequired, messageNotif: PropTypes.string.isRequired, }; const reducer = 'socmed'; const mapStateToProps = state => ({ force: state, // force state from reducer dataProps: state.getIn([reducer, 'dataTimeline']), commentIndex: state.getIn([reducer, 'commentIndex']), messageNotif: state.getIn([reducer, 'notifMsg']), }); const constDispatchToProps = dispatch => ({ fetchData: bindActionCreators(fetchAction, dispatch), submitPost: bindActionCreators(postAction, dispatch), submitComment: bindActionCreators(postCommentAction, dispatch), submitLike: bindActionCreators(toggleLikeAction, dispatch), fetchComment: bindActionCreators(fetchCommentAction, dispatch), closeNotif: () => dispatch(closeNotifAction), }); const SocialMediaMapped = connect( mapStateToProps, constDispatchToProps )(SocialMedia); export default SocialMediaMapped;