import {Provider, connect} from 'react-redux';
import {createStore, combineReducers, applyMiddleware, bindActionCreators} from 'redux';
import thunk from 'redux-thunk';
import {actionPromise, gql} from "./index";

import { useEffect } from 'react';



const actionGoods = (_id) => {

  return async dispatch => { 
    const queryJson = JSON.stringify([{
      "categories._id": `${_id}`
    }]);

    await dispatch(actionPromise(`goods`, gql (
      `query goods($query: String) {
        GoodFind(query: $query )  {
          name, price,
          images{url}, _id,
          description
          categories {
          _id
          createdAt
          name
          }
        }
      }` ,{ query:  queryJson })))
  }
}




 export default actionGoods;