import { fromJS } from 'immutable';
import {
  SEARCH_REQUEST,
  SEARCH_SUCCESS,
  SEARCH_ERROR,
  SELECT_BOOK,
  UNSELECT_BOOK,
} from './constants';

const initialState = fromJS({
  searching: false,
  error: false,
  books: false,
  selectedBook: false,
});

function addBookPageReducer(state = initialState, action) {
  switch (action.type) {
    case SEARCH_REQUEST:
      return state
        .set('error', false)
        .set('books', false)
        .set('selectedBook', false)
        .set('searching', true);
    case SEARCH_SUCCESS:
      return state
        .set('searching', false)
        .set('books', action.payload.books);
    case SEARCH_ERROR:
      return state
        .set('searching', false)
        .set('error', action.payload.error);
    case SELECT_BOOK:
      return state
        .set('selectedBook', action.payload.book);
    case UNSELECT_BOOK:
      return state
        .set('selectedBook', false);
    default:
      return state;
  }
}

export default addBookPageReducer;

@@ -229,24 +229,22 @@
 alse,%0A  
-selected
+active
 Book: fa
@@ -450,32 +450,30 @@
       .set('
-selected
+active
 Book', false
@@ -800,32 +800,30 @@
       .set('
-selected
+active
 Book', actio
@@ -900,16 +900,14 @@
 et('
-selected
+active
 Book

Rename selectedBook