import { actionPromise } from ".";
import gql from "../api";
import { actionRootCats } from ".";

const actionChangeCategName = (_id, name) => 
  async (dispatch) => { 
    await dispatch(actionPromise('newCategoryName', gql(`mutation categoryChange($category:CategoryInput){
    CategoryUpsert(category:$category){
      _id name
      }
    }`, {
      "category": {
        "_id": _id,
        "name": name}
    })))

    dispatch(actionRootCats())
  }

export default actionChangeCategName;