{"size": 606, "ext": "js", "max_stars_repo_path": "nattr/src/scripts/actions/post_actions.js", "max_stars_repo_name": "natotthomer/nattr", "max_stars_repo_stars_event_min_datetime": "2017-11-10T19:55:12.000Z", "max_stars_repo_stars_event_max_datetime": "2017-11-10T19:55:12.000Z", "max_issues_repo_path": "nattr/src/scripts/actions/post_actions.js", "max_issues_repo_name": "natotthomer/nattr", "max_issues_repo_issues_event_min_datetime": "2021-03-08T20:46:52.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-11T23:26:33.000Z", "max_forks_repo_path": "nattr/src/scripts/actions/post_actions.js", "max_forks_repo_name": "natotthomer/nattr", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 9, "max_forks_count": null, "avg_line_length": 26.347826087, "max_line_length": 76, "alphanum_fraction": 0.7194719472}
import * as API from '../utils/api_post'
import {
  RECEIVE_POST, RECEIVE_USER_POSTS
} from '../constants/post_constants'

const receiveUserPost = post => ({
  type: RECEIVE_POST,
  post
})

const receiveUserPosts = posts => ({
  type: RECEIVE_USER_POSTS,
  posts
})

export const createPost = data => dispatch => API.create(data)
  .then(response => dispatch(receiveUserPost(response)))
  .catch(error => console.log(error))

export const readUserPosts = userId => dispatch => API.readUserPosts(userId)
  .then(response => dispatch(receiveUserPosts(response.posts)))
  .catch(error => console.log(error))
