All files / src/containers/Privileges reducer.js

0% Statements 0/5
0% Branches 0/6
0% Functions 0/1
0% Lines 0/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22                                           
import {
  FETCH_PRIVILEGES_REQUEST,
  FETCH_PRIVILEGES_SUCCESS,
  FETCH_PRIVILEGES_FAILURE,
  FETCH_PRIVILEGES_INVALIDATE,
} from './actions';
import Privileges from './model';
 
export default function privileges(state = Privileges.create(), action) {
  switch (action.type) {
    case FETCH_PRIVILEGES_SUCCESS:
      return Privileges.create({ items: action.privileges });
    case FETCH_PRIVILEGES_INVALIDATE:
      return Privileges.create({ items: state.items, didInvalidate: true });
    case FETCH_PRIVILEGES_REQUEST:
    case FETCH_PRIVILEGES_FAILURE:
      return Privileges.create(); // Removes the data.
    default:
      return state;
  }
}