import React from 'react';
import {connect} from 'react-redux';
import PushItems from '../components/PushItems'
import {CHANGE_ASSAY, CHANGE_CHECK, ADD_BILLING} 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) {
        return {
        pushMessage: state.pushMessage,
        tipsDiscalimer:  state.copyRight.disContent
    }
}

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())
        }
    }
}

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

export default PushItemsComtainer;