import { DaffProduct } from '@daffodil/product' ; import { DaffProductGridActionTypes , DaffProductGridActions , } from '../../actions/public_api' ; import { DaffProductGridReducerState } from './product-grid-reducer-state.interface' ; /**
 * Initial values of the product grid state.
 */ export const initialState = { products : [ ] , loading : false , errors : [ ] , } ; param state param action returns export function daffProductGridReducer < T extends DaffProduct > ( state = initialState , action ) { switch ( action . type ) { case DaffProductGridActionTypes . ProductGridLoadAction : return { ... state , loading : true } ; case DaffProductGridActionTypes . ProductGridLoadSuccessAction : return { ... state , loading : false } ; case DaffProductGridActionTypes . ProductGridLoadFailureAction : return { ... state , loading : false , errors : state . errors . concat ( new Array ( action . payload ) ) } ; default : return state ; } }