import { AppStateWithHistory , MultiplayerState , SettingsType } from 'app/reducers/StateTypes' ; import { connect } from 'react-redux' ; import Redux from 'redux' ; import { ParserNode } from '../TemplateTypes' ; import { handleCombatTimerHold , handleCombatTimerStop , } from './Actions' ; import TimerCard , { DispatchProps , StateProps } from './TimerCard' ; import { mapStateToProps as mapStateToPropsBase } from './Types' ; const mapStateToProps = ( state , ownProps ) : StateProps => { const node = ownProps . node ; if ( ! node ) { throw Error ( 'Incomplete props given' ) ; } return { ... mapStateToPropsBase ( state , ownProps ) , combat : node . ctx . templates . combat , multiplayerState : state . multiplayer , numAliveAdventurers : state . quest . node . ctx . templates . combat . numAliveAdventurers , } ; } ; const mapDispatchToProps = ( dispatch ) : DispatchProps => { return { onTimerStop : ( node , settings , elapsedMillis , surge , seed , multiplayer ) => { if ( multiplayer . connected ) { dispatch ( handleCombatTimerHold ( { elapsedMillis } ) ) ; } else { dispatch ( handleCombatTimerStop ( { node , settings , elapsedMillis , seed } ) ) ; } } , } ; } ; export default connect ( mapStateToProps , mapDispatchToProps ) ( TimerCard ) ;