import fetch from 'isomorphic-fetch'
let domain = ENV.domain;
// let domain1='http://192.168.10.184:8080/maxbox/web/'
const willCloseDoor=(data)=>{
    let url=domain+`machine_pad/finish_task.action`
    let {userInfo,taskInfo,storeInfo}=data;
    console.log(data,'ahsdjhjaskhdjkhasjkd')
    let userId=userInfo.employeeId;
    let machineId=storeInfo.id;
    let {taskId,area,currentTaskType}=taskInfo;
    let bodyData={area,storeId:machineId,taskId,userId,taskType:currentTaskType}
    return (dispatch)=>{
        fetch(url,{
            // credentials : 'include',
            method : 'POST',
            mode : 'cors',
            headers:{
                'Access-Control-Allow-Origin': '*',
                'Content-Type': 'application/json; charset=UTF-8'
            },
            body:JSON.stringify(bodyData)
        }).then((response)=>response.json())
          .then((json)=>{
            //   console.log(json,'breakageContainerjs')
            //    dispatch(getSubmitStatus(json.meta))
          })
  }
}


const closeDoorSuccess=(data)=>{
    let {userInfo,taskInfo,storeInfo}=data;
    let userId=userInfo.employeeId;
    let machineId=storeInfo.id;
    let {taskId,area}=taskInfo;
    let bodyData={storeId:machineId,taskId,area,userId}
    let url=domain+'machine_pad/update_door_status.action'
    return (dispatch)=>{
        fetch(url,{
            // credentials : 'include',
            method : 'POST',
            mode : 'cors',
            headers:{
                'Access-Control-Allow-Origin': '*',
                'Content-Type': 'application/json; charset=UTF-8'
            },
            body:JSON.stringify(bodyData)
        }).then((response)=>response.json())
          .then((json)=>{
            //   console.log(json,'breakageContainerjs')
            //    dispatch(getSubmitStatus(json.meta))
          })
  }
}
export {willCloseDoor,closeDoorSuccess}