import fetch from 'isomorphic-fetch'
import {SUBMIT_NUM} from '../actiontype/TokeStokeContainer'
//初始的任务  返回工单
fetch(url,{
    credentials : 'include',
    method : 'POST',
    mode : 'cors',
    headers: {
        'content-type':'application/json;charset=UTF-8',
    },
    body:{}
}).then(response=>response.json())
  .then((data)=>{
     console.log(data)
  }).catch(e=>{console.log('err'+e)})


//点击提交后台核对商品数量  后台应该返回我ture 或者 false
const checkProductQuantity = (data)=>{
      let url=`http://192.168.10.128:8080/web/flat/barcode`
      return (dispatch)=>{
                fetch(url,{
                    credentials : 'include',
                    method : 'POST',
                    mode : 'cors',
                    headers: {
                        'content-type':'application/json;charset=UTF-8',
                    },
                    body:{}
                }).then(response=>response.json())
                .then((json)=>{
                    checkQuantity(json)
                }).catch(e=>{console.log('err'+e)})

      }
}
const checkQuantity = (data)=>{
      return{
          type :SUBMIT_NUM,
          data
      }
  }

  export {checkProductQuantity}