import React from 'react';
import {connect} from 'react-redux';
import Inspect from '@components/Inspect';
import {getSearchList,getSublableList} from '@store/async-actions/inspect';
import {setLabel,fillActived,fillActiveDetail,checkValueIsChange,delExcelLis,clearLabel,delPartItem} from '@store/actions/inspect';

function mapStateToProps(state) {
    return {
        list:state.inspect.list,
        labelList:state.inspect.labelList,
        fillActive:state.inspect.fillActive,
        getExcelDataList:state.inspect.getExcelDataList,
        labelListActive:state.inspect.labelListActive,
    }
}

function mapDispatchToProps(dispatch, store) {
    return {
        handleChangeValue(val){
            dispatch(getSearchList(val))
        },
        handleSign(id,idx){
            dispatch(setLabel(idx))
            dispatch(getSublableList(id))
        },
        handleLabelSub(e,id,idx){
            dispatch(fillActived(id,idx))
            // e.stopPropagation()
        },
        handleClear(e,idx){
            e.stopPropagation();
            dispatch(clearLabel(idx))
        },
        handleConfirm(e,idx,time,arr){
            e.stopPropagation();
            dispatch(checkValueIsChange(idx,time,arr))
        },
        changeActivePart(idx,value){
            console.log(idx,value)
            dispatch(fillActiveDetail(idx,value))
        },
        handleCloseExcel(idx){
            dispatch(delExcelLis(idx));
        },
        delPartItem(idx){
            dispatch(delPartItem(idx))
        }
    }
}

const InspectAction = connect(mapStateToProps, mapDispatchToProps)(Inspect);

export default InspectAction;