<commit_before>// @flow
import {resultOK} from 'api/utils'
import {getPostsAPI} from 'api/PostsSvc'
import type {PostItem} from 'types'
// Define action types
export const GET_POSTS_SUCCESS = 'GET_POSTS_SUCCESS'
export const GET_POSTS_FAIL = 'GET_POSTS_FAIL'
export const GET_POSTS_PENDING = 'GET_POSTS_PENDING'

export type GET_POSTS_SUCCESS_TYPE = {
	type: 'GET_POSTS_SUCCESS',
	payload: Array<PostItem>
}

export type GET_POSTS_PENDING_TYPE = {
	type: 'GET_POSTS_FAIL'
}

export type GET_POSTS_FAIL_TYPE = {
	type: 'GET_POSTS_PENDING',
	payload: {
		errors: void | Object
	}
}

export const GET_POSTS = () => async dispatch => {
	dispatch({type: GET_POSTS_PENDING})
	const result = await getPostsAPI()
	if (resultOK(result)) {
		dispatch({type: GET_POSTS_SUCCESS, payload: result.data})
	} else {
		dispatch({type: GET_POSTS_FAIL, payload: result.data})
	}<commit_msg>feat(actions/posts): add userId as param to GET_POSTS<commit_after>// @flow
import {resultOK} from 'api/utils'
import {getPostsAPI} from 'api/PostsSvc'
import type {PostItem} from 'types'
// Define action types
export const GET_POSTS_SUCCESS = 'GET_POSTS_SUCCESS'
export const GET_POSTS_FAIL = 'GET_POSTS_FAIL'
export const GET_POSTS_PENDING = 'GET_POSTS_PENDING'

export type GET_POSTS_SUCCESS_TYPE = {
	type: 'GET_POSTS_SUCCESS',
	payload: Array<PostItem>
}

export type GET_POSTS_PENDING_TYPE = {
	type: 'GET_POSTS_FAIL'
}

export type GET_POSTS_FAIL_TYPE = {
	type: 'GET_POSTS_PENDING',
	payload: {
		errors: void | Object
	}
}

export const GET_POSTS = (userId: number) => async dispatch => {
	dispatch({type: GET_POSTS_PENDING})
	const result = await getPostsAPI(userId)
	if (resultOK(result)) {
		dispatch({type: GET_POSTS_SUCCESS, payload: result.data})
	} else {
		dispatch({type: GET_POSTS_FAIL, payload: result.data})
	}
{'fraction_non_alphanumeric': 0.11265260821309656, 'fraction_numerical': 0.0, 'mean_word_length': 5.855513307984791, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5266150', 'n_tokens_mistral': 663, 'n_tokens_neox': 662, 'n_words': 154}