File size: 682 Bytes
f5071ca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import PostForm from './post_form';
import { createPost,fetchAllPosts } from '../../actions/post_actions';
const mapStateToProps = (state, ownProps) => {
const post = { body: '' };
const formType = 'Create Post';
const currentUserId = state.session.id;
return { post,currentUser:state.entities.users[currentUserId],
formType};
};
const mapDispatchToProps = (dispatch) => {
return {
action: post => dispatch(createPost(post)).then(()=>fetchAllPosts()),
fetch: ()=> dispatch(fetchAllPosts())
};
};
export default connect(mapStateToProps, mapDispatchToProps)(PostForm);
|