import React from 'react';
import { connect } from 'react-redux';
import Treat from '@components/Treat';
import { SELECT_DRUG, SET_OTHER_DRUG, SET_DRUG_INFO, HIDE_TREAT, CLEAR_TREAT, SHOW_DRUG_INFO, HIDE_DRUG_INFO } from '@store/types/treat.js';
import { getInstroduce, getRecommendBasic } from '@store/async-actions/treat';
import { ADD_SCHEME } from '@store/types/pushMessage.js'
import { showDrugInfo } from '../store/actions/treat';


function mapStateToProps(state){
    const { treat } = state;
    return {
        treatment: treat.treatment,
        generalTreat: treat.generalTreat,
        surgeryTreat: treat.surgeryTreat,
        treatDesc: treat.treatDesc,
        drugInfo: treat.drugInfo,
        showDrug: treat.showDrugInfo
    }
}
 
function mapDispatchToProps(dispatch) {
    return {
        selectDrug: (index, ii)=>{
            dispatch ({
                type: SELECT_DRUG,
                index: index,
                ii: ii
            })
        },
        setOtherRecommend: (item, index) => {
            dispatch ({
                type: SET_OTHER_DRUG,
                item: item,
                index: index,
            })
            //推荐依据不展示
            // dispatch(getRecommendBasic(item))
        },
        setDrugInfo: (item) => {
            dispatch(getInstroduce(item));
        },
        hideTreat: () => {
            dispatch({
                type: HIDE_TREAT
            })
        },
        clearTreat: () => {
            dispatch({
                type: CLEAR_TREAT
            })
        },
        showDrugInfo: () => {
            dispatch({
                type: SHOW_DRUG_INFO
            })
        },
        hideDrugInfo: () =>{
            dispatch({
                type: HIDE_DRUG_INFO
            })
        },
        addScheme: (title, treatment) => {
            dispatch({
                type: ADD_SCHEME,
                title: title,
                treatment: treatment
            })
        }
    }
}

const TreatContainer = connect(
    mapStateToProps,
    mapDispatchToProps
)(Treat)

export default TreatContainer;