ES6 Plato on Github
Report Home
Summary Display
reducers/investigations.js
Maintainability
60.85
Lines of code
36
Difficulty
23.18
Estimated Errors
0.20
Function weight
By Complexity
By SLOC
import { FECTH_INVESTIGATIONS_FULFILLED, FECTH_INVESTIGATIONS_PENDING, LOG_OUT } from '../constants/ActionTypes' const initialState = {fetching: false, fetched: false, initialized : false, data:[], error: null} const investigations = (state = initialState, action) => { switch (action.type) { case FECTH_INVESTIGATIONS_PENDING:{ state = {...state, fetched: false, fetching: true} break; } case FECTH_INVESTIGATIONS_FULFILLED: { state = {...state, data: action.payload.data.map((object,i ) => object.Investigation), fetched: true, fetching: false, initialized : true} break; } case LOG_OUT: { state = {...state, fetching: false, fetched: false, data: [], initialized : false}; break; } default: break; } return state; } export default investigations;