1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
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 (
<div>
<Helmet>
<title>{title}</title>
<meta name="description" content={description} />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="twitter:title" content={title} />
<meta property="twitter:description" content={description} />
</Helmet>
<Notification close={() => closeNotif()} message={messageNotif} />
<Grid
container
alignItems="flex-start"
justify="flex-start"
direction="row"
spacing={3}
>
<Grid item md={8} xs={12}>
<div>
<WritePost submitPost={submitPost} />
<Timeline
dataTimeline={dataProps}
onlike={submitLike}
submitComment={submitComment}
fetchComment={fetchComment}
commentIndex={commentIndex}
/>
</div>
</Grid>
<Grid item md={4} xs={12}>
<SideSection />
</Grid>
</Grid>
</div>
);
}
}
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;
|