import { numPlayers } from 'app/actions/Settings' ; import { connect } from 'react-redux' ; import Redux from 'redux' ; import { Quest } from 'shared/schema/Quests' ; import { toCard , toPrevious } from '../../actions/Card' ; import { previewQuest } from '../../actions/Quest' ; import { search } from '../../actions/Search' ; import { getContentSets } from '../../actions/Settings' ; import { NAV_CARDS } from '../../Constants' ; import { AppStateWithHistory , CardName , SearchParams , SettingsType } from '../../reducers/StateTypes' ; import { ParserNode } from './quest/cardtemplates/TemplateTypes' ; import Search , { DispatchProps , StateProps } from './Search' ; const mapStateToProps = ( state , ownProps ) : StateProps => { return { ... state . search , players : numPlayers ( state . settings , state . multiplayer ) , settings : state . settings , user : state . user , contentSets : getContentSets ( state . settings , state . multiplayer ) , } ; } ; const mapDispatchToProps = ( dispatch ) : DispatchProps => { return { onSearch : ( params , players , settings ) => { setTimeout ( ( ) => { dispatch ( search ( { params , players , settings } ) ) ; } , 1 ) ; } , toCard : ( name ) => { dispatch ( toCard ( { name } ) ) ; } , onQuest : ( quest ) => { dispatch ( previewQuest ( { quest } ) ) ; } , onReturn ( ) { dispatch ( toPrevious ( { matchFn : ( c , n ) => NAV_CARDS . indexOf ( c ) === - 1 , } ) ) ; } , } ; } ; const SearchContainer = connect ( mapStateToProps , mapDispatchToProps ) ( Search ) ; export default SearchContainer ;