actionOrdersFind.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import {actionPromise, gql} from "./index";
  2. const actionOrdersFind = (data) => {
  3. return async dispatch => {
  4. const queryJson = JSON.stringify(
  5. [{"___owner" : data}]
  6. )
  7. await dispatch(actionPromise("ordersFind", gql (
  8. `query orders ($query: String) {
  9. OrderFind(query: $query){
  10. total
  11. _id
  12. orderGoods {count, _id, price, good {name, _id, price, images {url}}}
  13. createdAt
  14. owner {
  15. login
  16. }
  17. }
  18. }`, {query: queryJson}
  19. )))
  20. }
  21. }
  22. const actionOrderFindOne = (_id) => {
  23. return async dispatch => {
  24. const queryJson = JSON.stringify([{
  25. "_id": `${_id}`
  26. }]);
  27. await dispatch(actionPromise("oneOrder", gql(
  28. `query oneOrder($query: String) {
  29. OrderFindOne(query: $query) {
  30. total
  31. _id
  32. orderGoods {count, _id, price, good {name, _id, price, images {url}}}
  33. createdAt
  34. }
  35. }`, {query: queryJson}
  36. )))
  37. }
  38. }
  39. export {actionOrdersFind, actionOrderFindOne};