actionCatsFind.js 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. import { gql } from "../helpers";
  2. import { actionPromise } from "../reducers";
  3. export const actionCatsFind =
  4. ({ text = "", limit = 7, skip = 0, promiseName = "catsFind", orderBy = "_id" }) =>
  5. async (dispatch, getState) => {
  6. dispatch(
  7. actionPromise(
  8. promiseName,
  9. gql(
  10. `query CatsFind($query:String){
  11. CategoryFind(query: $query){
  12. _id name
  13. parent{
  14. _id name
  15. }
  16. }
  17. }`,
  18. {
  19. query: JSON.stringify([
  20. { name__contains: text, _id__contains: text },
  21. {
  22. limit: !!limit ? limit : 5,
  23. skip,
  24. orderBy,
  25. },
  26. ]),
  27. }
  28. )
  29. )
  30. );
  31. };