{"size": 613, "ext": "js", "max_stars_repo_path": "react-redux-project-boilerplate/src/sample/sample.reducer.js", "max_stars_repo_name": "ChenFeldman/storybook-sandbox", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "react-redux-project-boilerplate/src/sample/sample.reducer.js", "max_issues_repo_name": "ChenFeldman/storybook-sandbox", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "react-redux-project-boilerplate/src/sample/sample.reducer.js", "max_forks_repo_name": "ChenFeldman/storybook-sandbox", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.7037037037, "max_line_length": 80, "alphanum_fraction": 0.6884176183}
// @flow
import { get, set, keyBy } from 'lodash/fp';
import { handleActions } from 'redux-actions';

import type { PostsMap } from 'sample/sample.types';
import type { SetPostsAction } from 'sample/sample.actions';

import * as AT from 'sample/sample.actions';

export type SampleState = {|
  +posts: PostsMap
|};

const initialState: SampleState = {
  posts: {}
};

const sampleReducer = handleActions(
  {
    [AT.SET_POSTS]: (state: SampleState, action: SetPostsAction): SampleState =>
      set('posts', keyBy('id', get('payload.posts', action)), state)
  },
  initialState
);

export default sampleReducer;
