ActionOrder.js 589 B

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