<commit_before>import { ItemActions } from './item.actions';
import { IPayloadAction } from '../../utils/payload-action.types';
import { IItem, ItemType } from './item.types';

const INITIAL_STATE: IItem = {
  error: null,
  item: {},
  itemType: null,
  loading: false,
};

// A higher-order reducer: accepts an animal type and returns a reducer
// that only responds to actions for that particular animal type.
export function createItemReducer(itemType: ItemType) {
  return function animalReducer(state: IItem = INITIAL_STATE,
                                action: IPayloadAction<IItem, any>): IItem {
    if (!action.meta || action.meta.itemType !== itemType) {
      return state;
    }

    switch (action.type) {
      case ItemActions.LOAD_STARTED:
        return {
          error: null,
          item: null,
          itemType: null,
          loading: true,
        };
      case ItemActions.LOAD_SUCCEEDED:
        return {
          error: null,
          item: action.payload,
          itemType: action.meta.itemType,
          loading: false,
        };
      case ItemActions.LOAD_FAILED:<commit_msg>Remove references to animal.<commit_after>import { ItemActions } from './item.actions';
import { IPayloadAction } from '../../utils/payload-action.types';
import { IItem, ItemType } from './item.types';

const INITIAL_STATE: IItem = {
  error: null,
  item: {},
  itemType: null,
  loading: false,
};

// A higher-order reducer: accepts an item type and returns a reducer
// that only responds to actions for that particular item type.
export function createItemReducer(itemType: ItemType) {
  return function itemReducer(state: IItem = INITIAL_STATE,
                                action: IPayloadAction<IItem, any>): IItem {
    if (!action.meta || action.meta.itemType !== itemType) {
      return state;
    }

    switch (action.type) {
      case ItemActions.LOAD_STARTED:
        return {
          error: null,
          item: null,
          itemType: null,
          loading: true,
        };
      case ItemActions.LOAD_SUCCEEDED:
        return {
          error: null,
          item: action.payload,
          itemType: action.meta.itemType,
          loading: false,
        };
      case ItemActions.LOAD_FAILED:
{'fraction_non_alphanumeric': 0.10706352732119058, 'fraction_numerical': 0.0, 'mean_word_length': 2.326440177252585, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7580668', 'n_tokens_mistral': 650, 'n_tokens_neox': 643, 'n_words': 180}