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 } from '@store/async-actions/assistCheck';

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

function mapDispatchToProps(dispatch, store) {
    return {
        handleChangeValue(val) {
            dispatch(getSearchList(val))
        },
        handleSign(id){
            dispatch(assistLable(id))
        },
        handleDelAssist(idx){
            dispatch(delAssistLabel(idx))
        },
        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))
        }
    }
}

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

export default AssistCheckAction;