'use strict'

import {
  FILL_FILTER_SELECTS,
  CHOOSE_FILTER_SELECT
} from '../actions/index'

const initialState = {
  months: {
    icon: { id: 'date', label: 'Data' },
    label: 'Escolha um mês',
    selected: '',
    options: [{
      text: 'Escolha um mês', value: ''
    }]
  },

  state: {
    icon: { id: 'location', label: 'Estado' },
    label: 'Escolha um estado',
    selected: '',
    options: [{
      text: 'Escolha um estado', value: ''
    }]
  },

  searchField: ''
}

const filter = (state = initialState, action) => {
  switch (action.type) {
    case FILL_FILTER_SELECTS:
      return {
        ...state,
        [action.payload.select]: {
          ...state[action.payload.select],
          options: [
            ...state[action.payload.select].options,
            ...action.payload.options
          ]
        }
      }

    case CHOOSE_FILTER_SELECT:
      return {
        ...state,
        [action.payload.field]: {
          ...state[action.payload.field],
          selected: action.payload.value
        }
      }
  }
  return state
}

export default filter

@@ -61,16 +61,34 @@
 R_SELECT
+,%0A  FILTER_BY_TEXT
 %0A%7D from 
@@ -1058,16 +1058,125 @@
 %0A      %7D
+%0A%0A    case FILTER_BY_TEXT:%0A      return %7B%0A        ...state,%0A        searchField: action.payload.value%0A      %7D
 %0A  %7D%0A  r

Update filter reducer to update by text