actionOrderUpsert.js 797 B

1234567891011121314151617181920212223242526272829303132
  1. import { gql } from "../helpers";
  2. import { actionCartClear, actionPromise } from "../reducers";
  3. export const actionOrderUpsert = (order) => async (dispatch, getState) => {
  4. if (!order?.orderGoods?.length) {
  5. return;
  6. }
  7. await dispatch(
  8. actionPromise(
  9. "orderUpsert",
  10. gql(
  11. `mutation newOrder($order:OrderInput!){
  12. OrderUpsert(order:$order){
  13. _id price
  14. }
  15. }
  16. `,
  17. {
  18. order,
  19. }
  20. )
  21. )
  22. );
  23. let {
  24. promise: { orderUpsert },
  25. } = getState();
  26. if (orderUpsert.status === "FULFILLED") {
  27. dispatch(actionCartClear());
  28. // dispatch(actionOrders(token));
  29. }
  30. };