2019-09-12 15:51:45 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
|
|
|
|
import { requestPost } from '../actions/requestPost';
|
2019-09-30 16:54:37 +02:00
|
|
|
import { requestLikes } from '../actions/requestLikes';
|
2019-09-21 12:54:57 +02:00
|
|
|
import { changePostBoard } from '../actions/changePostBoard';
|
2019-09-12 15:51:45 +02:00
|
|
|
import { changePostStatus } from '../actions/changePostStatus';
|
|
|
|
|
|
|
|
|
|
import { State } from '../reducers/rootReducer';
|
|
|
|
|
|
|
|
|
|
import PostP from '../components/Post/PostP';
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state: State) => ({
|
2019-09-17 11:33:18 +02:00
|
|
|
post: state.currentPost.item,
|
2019-09-30 16:54:37 +02:00
|
|
|
likes: state.currentPost.likes,
|
2019-09-12 15:51:45 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
requestPost(postId: number) {
|
|
|
|
|
dispatch(requestPost(postId));
|
|
|
|
|
},
|
|
|
|
|
|
2019-09-30 16:54:37 +02:00
|
|
|
requestLikes(postId: number) {
|
|
|
|
|
dispatch(requestLikes(postId));
|
|
|
|
|
},
|
|
|
|
|
|
2019-09-21 12:54:57 +02:00
|
|
|
changePostBoard(postId: number, newBoardId: number, authenticityToken: string) {
|
|
|
|
|
dispatch(changePostBoard(postId, newBoardId, authenticityToken));
|
|
|
|
|
},
|
|
|
|
|
|
2019-09-12 15:51:45 +02:00
|
|
|
changePostStatus(postId: number, newPostStatusId: number, authenticityToken: string) {
|
2019-09-12 18:03:19 +02:00
|
|
|
if (isNaN(newPostStatusId)) newPostStatusId = null;
|
|
|
|
|
|
2019-09-12 15:51:45 +02:00
|
|
|
dispatch(changePostStatus(postId, newPostStatusId, authenticityToken));
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
|
mapStateToProps,
|
|
|
|
|
mapDispatchToProps,
|
|
|
|
|
)(PostP);
|