import fetch from 'isomorphic-fetch'
import actionType from '../actiontype/error'
let domain = ENV.domain;

var myHeaders = new Headers({
    'Access-Control-Allow-Origin': '*',
    // 'Content-Type': 'text/plain;charset=UTF-8',
    // 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    'Content-Type': 'application/json; charset=UTF-8',
});
const uploadError = (info)=>{
    let bodyData = {
        warehouseId : info.storeId,
        exceptionType : info.exceptionType,
        taskId : info.taskId
    };
    return (dispatch =>{
        fetch(domain + '/machine_pad/flat_warn_record',{
            credentials : 'include',
            method : 'POST',
            mode : 'cors',
            headers:myHeaders,
            body : JSON.stringify(bodyData)

        }).then((response)=>response.json())
            .then(json=>{
            }).catch(e=>{console.error(e)});
    })
};

const addErrorInfo = (errMsg)=>{
    return{
        type : actionType.ADDERRORINFO,
        errMsg
    }
}

export {uploadError,addErrorInfo}