import React from 'react';
import {connect} from 'react-redux';
import PushItems from '../components/PushItems'
import {CHANGE_ASSAY, CHANGE_CHECK, ADD_BILLING, SHOW_TIPS_DETAILS, HIDE_TIPS_DETAILS,SHOW_TABLE_LIST} from '@store/types/pushMessage';
import { ADD_DIAGNOSTIC, GET_DIAGNOSTIC_STR } from '@store/types/diagnosticList';
import {billing, getTips, getTipsDetails} from '../store/async-actions/pushMessage';
import { isAddMainSuit } from '@store/async-actions/diagnosticList';

function mapStateToProps(state) {
  const {pushMessage,diagnosticList} = state;
        return {
        pushMessage: pushMessage,
        tipsDiscalimer:  state.copyRight.disContent,
        chronicMagItem: diagnosticList.chronicMagItem,
        questionId: diagnosticList.clickDiag,
        tableList: pushMessage.tableList,
        showList: pushMessage.showList,
        chronicPushItems: pushMessage.chronicPushItems,
    }
}

function mapDispatchToProps(dispatch) {
    return {
        changeAssay: (item) => {
            dispatch({type: CHANGE_ASSAY, item})
        },
        changeCheck: (item) => {
            dispatch({type: CHANGE_CHECK, item})
        },
        addDiagnostic: (item) => {
            dispatch({
                type: ADD_DIAGNOSTIC,
                item: item
            });
            dispatch({
                type: GET_DIAGNOSTIC_STR
            });
            dispatch(isAddMainSuit())
            dispatch(billing());
        },
        billing: (checkedAssay, checkedCheck) => {
            // dispatch(billing)
            dispatch({
                type: ADD_BILLING, //添加开单项
                assay: checkedAssay,
                check: checkedCheck,
            })
        },
        getTips: (diagItem) => {
            dispatch(getTips(diagItem))
        },
        getTipsDetails: () => {
            dispatch(getTipsDetails())
        },
        showTipsDetailsModal: () => {
            dispatch({
                type: SHOW_TIPS_DETAILS
            })
        },
        hideTipsDetailsModal: () => {
            dispatch({
                type: HIDE_TIPS_DETAILS
            })
        }
    }
}

const PushItemsComtainer = connect(
    mapStateToProps,
    mapDispatchToProps
)(PushItems);

export default PushItemsComtainer;