import React from 'react';
import { connect } from 'react-redux';
import { getSearchList } from '@store/async-actions/scaleSearch';
import ScaleSearch from '@components/ScaleSearch';
import {getScaleInfo} from '../store/async-actions/pushMessage';
import {SHOW_TABLE_LIST} from '@store/types/pushMessage';
import {CLEAR_SCALE_SEARCH_LIST} from '@types/scaleSearch';

function mapStateToProps(state) {
    const {pushMessage} = state;
    return{
        searchResult: state.scaleSearch.searchResult,
        formulaResult: pushMessage.formulaResult,//????????
        scaleInfo: pushMessage.scaleInfo,//量表内容
    }
}

function mapDispatchToProps(dispatch) {
    return {
        handleChangeValue(val){
            dispatch(getSearchList(val))
        },
        getScale(item) {
            dispatch(getScaleInfo(item))
        },
        showScaleFn(item,isPop){
          dispatch({
            type:SHOW_TABLE_LIST,
            name:'showTable',
            value:true,
            isPop,
            item:Object.assign({},item)
          });
        },
        clearResult(){
            dispatch({
              type:CLEAR_SCALE_SEARCH_LIST
            })
        }
    }
}
const ScaleSearchContainer = connect(
    mapStateToProps,
    mapDispatchToProps
)(ScaleSearch);

export default ScaleSearchContainer
