import { actionPromise, actionGoodById } from '.';
import gql from '../api';

const actionChangeArrInGood = (_id, arr) =>
  async (dispatch) => {
    await dispatch(actionPromise('changeArrInGood', gql(`mutation changeArrImgInGood ($good:GoodInput){
      GoodUpsert(good:$good){
        _id name
      }
    }`, {
      good: {
        _id,
        images: arr
      }
    })));

    dispatch(actionGoodById(_id));
  };

export default actionChangeArrInGood;
