ActionOrder.js 576 B

1234567891011121314151617
  1. const {actionPromise} = require("../reducers/PromiseReducer");
  2. const {gql} = require("./PathDB");
  3. export const ActionOrder = (orderGoods) => {
  4. return actionPromise('order', gql(`
  5. mutation order($order:OrderInput){
  6. OrderUpsert(order:$order)
  7. { _id total }
  8. }
  9. `, {order: {orderGoods}}))
  10. }
  11. export const ActionFullOrder = (card) =>
  12. async (dispatch) => {
  13. let orderGoods = Object.entries(card).map(([_id, {count}]) => ({good: {_id}, count}))
  14. await dispatch(ActionOrder(orderGoods))
  15. }