import React from 'react';
import {
    connect
} from 'react-redux';
import AssistCheck from '@components/AssistCheck';
import { assistLable,delAssistLabel,changeAssistVal,changeDate } from '@store/actions/assistCheck';
import { getSearchList,getInstroduce } from '@store/async-actions/assistCheck';
import {ISREAD} from '@store/types/homePage.js';
import {billing} from '@store/async-actions/pushMessage';

function mapStateToProps(state) {
    return {
        list:state.assistCheck.list,
        assistLabel:state.assistCheck.assistLabel,
        isRead:state.homePage.isRead,
        winWidth:state.homePage.windowWidth,
        assistList:state.homePage.assistList,
        assistVal:state.assistCheck.assistVal,
    }
}

function mapDispatchToProps(dispatch, store) {
    return {
        getInfomation(id,name){
            dispatch(getInstroduce(id,name))
        },
        handleChangeValue(val) {
            dispatch(getSearchList(val))
        },
        handleSign(id,idx,type){
            dispatch(assistLable(id,idx,type))
        },
        handleDelAssist(idx){
            dispatch(delAssistLabel(idx))
            dispatch({
              type:ISREAD
            })
        },
        handleChangeAssistValue(val,idx){
            dispatch(changeAssistVal(val,idx))
        },
        handleChangeDate(info,idx){
            let date = info.year+'-'+(info.month<10?'0'+info.month:info.month)+'-'+(info.day<10?'0'+info.day:info.day);
            dispatch(changeDate(date,idx))
        },
        //右侧推送
        fetchPushInfos(){
          //调右侧推送
          dispatch(billing());
        }
    }
}

const AssistCheckAction = connect(mapStateToProps, mapDispatchToProps)(AssistCheck);

export default AssistCheckAction;