actionGoodsFind.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { gql } from "../helpers";
  2. import { actionPromise } from "../reducers";
  3. export const actionGoodsFind =
  4. ({ text = "", limit = 7, skip = 0, promiseName = "goodsFind", orderBy = "_id" }) =>
  5. async (dispatch, getState) => {
  6. dispatch(
  7. actionPromise(
  8. promiseName,
  9. gql(
  10. `query GoodsFind($query:String){
  11. GoodFind(query: $query){
  12. _id name price images{
  13. _id url
  14. }
  15. categories{
  16. _id name
  17. }
  18. amount
  19. }
  20. }`,
  21. {
  22. query: JSON.stringify([
  23. {
  24. name__contains: text,
  25. description__contains: text,
  26. },
  27. {
  28. limit: !!limit ? limit : 5,
  29. skip,
  30. orderBy,
  31. },
  32. ]),
  33. }
  34. )
  35. )
  36. );
  37. };