import { ISimpleAction , Batch , BatchResponse } from 'types' ; const initialState = { data : { } , error : null } ; const batchList = ( state = initialState , action ) : any => { switch ( action . type ) { case 'LIST_BATCH_SUCCESS' : { return { data : action . payload ? action . payload . reduce ( ( acc , batch ) => ( { ... acc , [ batch . id ] : { ... batch } } ) , { } ) : [ ] , error : null } ; } case 'LIST_BATCH_FAILED' : { return { ... state , error : action . payload } ; } default : return state ; } } ; export default batchList ;