import { actionPromise, actionCatById } from ".";
import gql from "../api";

const actionChangeOneGood = (_id, name, description, price, idImg) =>
  async (dispatch) => {
    await dispatch(actionPromise('changeGood', gql(`mutation changeGood($good:GoodInput){
      GoodUpsert(good:$good){
        _id name
      }
    }`, {
          "good":{
          "_id": _id,
          "description": description,
          "name": name, 
          "price": price,
          "images": [{"_id": idImg}]
        } 
    })))

    dispatch(actionCatById())
}

export default actionChangeOneGood; 