import {actionPromise, gql} from "./index";



const actionOrderUpdate = (id, arrGoods) => {

    return async dispatch => {

        const queryJson = JSON.stringify(
        {
            newOrder: {
                _id: id,
                orderGoods: arrGoods
            }
        });

        await dispatch(actionPromise("orderUpdated", gql (
            `mutation orderChange($newOrder: OrderInput) {
                OrderUpsert(order: $newOrder) {
                  
                  total
                  orderGoods {good {name}}
                  owner {_id, login}
                }
              }`, queryJson
        )))
    }
}

export default actionOrderUpdate;