import { DaffCountry } from '@daffodil/geography' ; import { DaffGeographyActions , DaffGeographyActionTypes , } from '../../actions/public_api' ; import { daffGeographyInitialState } from './geography-initial-state' ; import { DaffGeographyReducerState } from './geography-state.interface' ; export function daffGeographyReducer < T extends DaffCountry > ( state = daffGeographyInitialState , action ) { switch ( action . type ) { case DaffGeographyActionTypes . CountryLoadAction : case DaffGeographyActionTypes . CountryListAction : return { ... state , loading : true } ; case DaffGeographyActionTypes . CountryLoadSuccessAction : case DaffGeographyActionTypes . CountryListSuccessAction : return { ... state , errors : [ ] , loading : false , } ; case DaffGeographyActionTypes . CountryLoadFailureAction : case DaffGeographyActionTypes . CountryListFailureAction : return { ... state , errors : [ ... state . errors , action . payload , ] , loading : false , } ; default : return state ; } }