import fetch from 'isomorphic-fetch';
import actionType from '../actiontype/recovery'
import {getTaskList} from "./common";
const domain = ENV.domain;

let 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 finishBoxRecovery = ()=>{
    //完成
    let url=`${ENV.domain}/machine_pad/update_machine_recovery_sku.action`
    return (dispatch)=>{
        fetch(url,{
            // credentials : 'include',
            method : 'POST',
            mode : 'cors',
            headers: myHeaders
        }).then(response=>response.json())
            .then((json)=>{
                dispatch(getTaskList());
            })
    }
};

const wrongShelf = ()=>{
    //货道不符
    let url=`${ENV.domain}/machine_pad/wrong_machine_recovery_sku.action`
    return (dispatch)=>{
        fetch(url,{
            // credentials : 'include',
            method : 'POST',
            mode : 'cors',
            headers: myHeaders
        }).then(response=>response.json())
            .then((json)=>{
                dispatch(getTaskList());
            })
    }
}

export {finishBoxRecovery,wrongShelf}
