actionOrderUpdate.js 761 B

12345678910111213141516171819202122
  1. import { call, put, select } from "redux-saga/effects";
  2. import { actionCartClear } from "../reducers";
  3. import { promiseWorker } from "../reducers/promiseReducer";
  4. import { actionOrdersAll } from "./actionOrdersAll";
  5. import { actionOrderUpsert } from "./actionOrderUpsert";
  6. export const actionOrderUpdate = (order) => ({ type: "ORDER_UPDATE", payload: order });
  7. export function* orderUpdateWorker(action) {
  8. const order = action.payload || {};
  9. if (!order?.orderGoods?.length) {
  10. return;
  11. }
  12. yield call(promiseWorker, actionOrderUpsert(order));
  13. yield put(actionOrdersAll());
  14. const {
  15. promise: { orderUpsert },
  16. } = yield select();
  17. if (orderUpsert.status === "FULFILLED") {
  18. yield put(actionCartClear());
  19. }
  20. }