import { Reducer , Action } from 'redux' ; import { AnimalComponent } from './component' ; export const ticketsReducer = ( state = 0 , action ) : number => { switch ( action . type ) { case AnimalComponent . ADD_TICKET : return state + 1 ; case AnimalComponent . REMOVE_TICKET : return Math . max ( 0 , state - 1 ) ; } return state ; } ; export const animalComponentReducer = ( state = { } , action ) : { } => ( { ... state , tickets : ticketsReducer ( state . tickets , action ) , } ) ;