import React from 'react';
import {connect} from 'react-redux';
import Advice from '../components/Advice'
import { SET_CHANGE_ADVICE_TREATMENT, SET_CHANGE_ADVICE_ASSAY, SET_CHANGE_ADVICE_CHECK, SET_COMMONTREATMENT ,SET_ADVICE_INPUT, SAVE_FOLLOW_UP} from '@store/types/pushMessage';

function mapStateToProps(state) {
    return ({
        pushMessage: state.pushMessage,
        isRead:state.homePage.isRead,
        adviceInput: state.pushMessage.advice.adviceInput,
        isFirstMainDiag:  state.treat.isFirstMainDiag,
        followUp: state.pushMessage.advice.followUp,
        hasFollowUp: state.treat.hasFollowUp
    })
}

function mapDispatchToProps(dispatch) {
    return {
        setChangeAdviceTreatment: (index, ii, changeInput) => {
            dispatch({
                type: SET_CHANGE_ADVICE_TREATMENT,
                index: index,
                ii: ii,
                changeInput: changeInput,
            })
        },
        setChangeAdviceAssay: (changeInput) => {
            dispatch({
                type: SET_CHANGE_ADVICE_ASSAY,
                changeInput:changeInput
            })
        },
        setChangeAdviceCheck: (changeInput) => {
            dispatch({
                type: SET_CHANGE_ADVICE_CHECK,
                changeInput:changeInput
            })
        },
        comTreatChange: (text) => {
            dispatch({
                type: SET_COMMONTREATMENT,
                commontreatment: text,
            })
        },
        adviceInputChange: (text) => {
            dispatch({
                type: SET_ADVICE_INPUT,
                adviceInput: text,
            })
        },
        saveFollowUp: (followUp) => {
            dispatch({
                type: SAVE_FOLLOW_UP,
                followUp: followUp
            })
        },
    }
}

const AdviceContainer = connect(
    mapStateToProps,
    mapDispatchToProps
)(Advice);

export default AdviceContainer;