actionGoodPage.js 786 B

1234567891011121314151617181920212223242526
  1. import { put, take } from "redux-saga/effects";
  2. import { actionPromiseClear } from "../reducers";
  3. import { actionCatAll } from "./actionCatAll";
  4. import { actionGoodById } from "./actionGoodById";
  5. export const actionGoodPage = ({ _id, promiseName } = {}) => ({
  6. type: "GOOD_PAGE",
  7. payload: { _id, promiseName },
  8. });
  9. export function* goodPageWorker(action) {
  10. const { _id, promiseName = "goodById" } = action.payload;
  11. yield put(actionCatAll());
  12. if (_id) {
  13. yield put(actionGoodById({ _id, promiseName }));
  14. } else {
  15. yield put(actionPromiseClear(promiseName));
  16. }
  17. yield take("GOOD_PAGE_CLEAR");
  18. yield put(actionPromiseClear(promiseName));
  19. yield put(actionPromiseClear("goodsAll"));
  20. yield put(actionPromiseClear("goodUpsert"));
  21. }