import React from 'react';
import { connect } from 'react-redux';
import HistoryCaseContainer from '@components/HistoryCaseContainer';
import { showHistory,sortHistory,activeHistory,visibleHistory } from '@store/actions/historyTemplates'
import {keepPushData} from '@store/actions/tabTemplate';

function mapStateToProps(state) {
    return {
        showHistoryCases:state.historyTemplates.showHistoryCases,
        activeHistory:state.historyTemplates.activeHistory,
        items:state.historyTemplates.items,
        visible:state.historyTemplates.visible,
        preInfo : state.patInfo.message
    }
}


function mapDispatchToProps(dispatch) {
    return {
        showHistoryBox(){
            dispatch(showHistory(false))
        },
        handleCaseClick(e,val){
            e.stopPropagation();
            dispatch(activeHistory(val))
        },
        handleQuoteClick(e,data,idx){
            e.stopPropagation();
            dispatch(keepPushData(data,'his'))      //历史病历引用
            dispatch(activeHistory(idx))
            dispatch(visibleHistory(true))
        },
        handleSortClick(){
            dispatch(sortHistory())
        }
    }
}

const HistoryCases = connect(
    mapStateToProps,
    mapDispatchToProps
)(HistoryCaseContainer);
export default HistoryCases;
