<commit_before>import { Actions } from '../actions/recipe';
import { RecipeState } from '../types/index';
import {
  RECIPE_ADD_CATEGORY, RECIPE_CHANGE_CATEGORY_NAME,
  RECIPE_CHANGE_CATEGORY_DESCRIPTION,
  RECIPE_ADD_RECIPE,
  RECIPE_CHANGE_RECIPE_NAME,
  RECIPE_CHANGE_RECIPE_URL
} from '../constants/index';

const initialState: RecipeState = {
  categories: [],
  recipes: [],
  nextCategoryId: 0,
  nextRecipeId: 0,
  newCategoryName: '',
  newCategoryDescription: ''
};

export function recipes(state: RecipeState = initialState, action: Actions): RecipeState {
  switch (action.type) {
    case RECIPE_ADD_CATEGORY:
      return {
        ...state,
        categories: [...state.categories,
        { id: state.nextCategoryId, name: state.newCategoryName, description: state.newCategoryDescription }
        ],
        nextCategoryId: state.nextCategoryId + 1,
        newCategoryName: '',
        newCategoryDescription: ''
      };
    case RECIPE_CHANGE_CATEGORY_NAME:
      return {
        ...state,
        newCategoryName: action.newName
      };
    case RECIPE_CHANGE_CATEGORY_DESCRIPTION:
      return {
        ...state,
        newCategoryDescription: action.newDescription
      };
    case RECIPE_ADD_RECIPE:
      return {
        ...state,
        recipes: [...state.recipes,
        { id: state.nextRecipeId, name: state.newRecipeName, url: state.newRecipeUrl, categoryId: 1 }
        ],
        nextRecipeId: state.nextRecipeId + 1,
        newRecipeName: '',
        newRecipeUrl: ''
      };
    case RECIPE_CHANGE_RECIPE_NAME:
      return {
        ...state,
        newRecipeName: action.newName
      };
    case RECIPE_CHANGE_RECIPE_URL:
      return {
        ...state,
        newRecipeUrl: action.newUrl
      };
    default:
      return state;
  }
}
<commit_msg>fix initial state<commit_after>import { Actions } from '../actions/recipe';
import { RecipeState } from '../types/index';
import {
  RECIPE_ADD_CATEGORY, RECIPE_CHANGE_CATEGORY_NAME,
  RECIPE_CHANGE_CATEGORY_DESCRIPTION,
  RECIPE_ADD_RECIPE,
  RECIPE_CHANGE_RECIPE_NAME,
  RECIPE_CHANGE_RECIPE_URL
} from '../constants/index';

const initialState: RecipeState = {
  categories: [],
  recipes: [],
  nextCategoryId: 0,
  nextRecipeId: 0,
  newCategoryName: '',
  newCategoryDescription: '',
  newRecipeName: '',
  newRecipeUrl: ''
};

export function recipes(state: RecipeState = initialState, action: Actions): RecipeState {
  switch (action.type) {
    case RECIPE_ADD_CATEGORY:
      return {
        ...state,
        categories: [...state.categories,
        { id: state.nextCategoryId, name: state.newCategoryName, description: state.newCategoryDescription }
        ],
        nextCategoryId: state.nextCategoryId + 1,
        newCategoryName: '',
        newCategoryDescription: ''
      };
    case RECIPE_CHANGE_CATEGORY_NAME:
      return {
        ...state,
        newCategoryName: action.newName
      };
    case RECIPE_CHANGE_CATEGORY_DESCRIPTION:
      return {
        ...state,
        newCategoryDescription: action.newDescription
      };
    case RECIPE_ADD_RECIPE:
      return {
        ...state,
        recipes: [...state.recipes,
        { id: state.nextRecipeId, name: state.newRecipeName, url: state.newRecipeUrl, categoryId: 1 }
        ],
        nextRecipeId: state.nextRecipeId + 1,
        newRecipeName: '',
        newRecipeUrl: ''
      };
    case RECIPE_CHANGE_RECIPE_NAME:
      return {
        ...state,
        newRecipeName: action.newName
      };
    case RECIPE_CHANGE_RECIPE_URL:
      return {
        ...state,
        newRecipeUrl: action.newUrl
      };
    default:
      return state;
  }
}

{'fraction_non_alphanumeric': 0.10815262146582487, 'fraction_numerical': 0.002744990392533626, 'mean_word_length': 2.5760549558390577, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2451878', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1160, 'n_words': 206}