Files
astuto/app/javascript/containers/Post.tsx

40 lines
1.1 KiB
TypeScript
Raw Normal View History

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) => ({
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);