Last active
August 29, 2016 18:45
-
-
Save KensoDev/ce591a0d2d2ee134800db715e7e1c02c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as actionTypes from '../../constants/actionTypes'; | |
| const initialState = { | |
| selected: ['Hotel'], | |
| } | |
| export default function itemTypeReducer(state = initialState, action) { | |
| let selected = state.selected.slice(0); | |
| let newArray = null; | |
| if (action.type == actionTypes.TOGGLE_ITEM_TYPE) { | |
| if (selected.indexOf(action.itemType) >= 0) { | |
| newArray = selected.filter((item) => { | |
| return item != action.itemType | |
| }); | |
| return { | |
| selected: newArray | |
| } | |
| } else { | |
| newArray = selected.concat([action.itemType]) | |
| return { | |
| selected: newArray | |
| } | |
| } | |
| } | |
| return state; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment