2019-09-27 16:05:33 +00:00
|
|
|
import {
|
|
|
|
|
ReduxActionTypes,
|
|
|
|
|
ReduxActionErrorTypes,
|
2019-11-25 05:07:27 +00:00
|
|
|
} from "constants/ReduxActionConstants";
|
|
|
|
|
import WidgetSidebarApi, { WidgetSidebarResponse } from "api/WidgetSidebarApi";
|
|
|
|
|
import { successFetchingWidgetCards } from "actions/widgetSidebarActions";
|
2019-09-25 17:24:23 +00:00
|
|
|
import { call, put, takeLatest, all } from "redux-saga/effects";
|
2019-08-21 12:49:16 +00:00
|
|
|
|
2019-09-09 09:08:54 +00:00
|
|
|
export function* fetchWidgetCards() {
|
2019-08-21 12:49:16 +00:00
|
|
|
try {
|
2019-10-18 08:16:26 +00:00
|
|
|
const widgetCards: WidgetSidebarResponse = yield all([
|
|
|
|
|
call(WidgetSidebarApi.fetchWidgetCards),
|
2019-09-25 17:24:23 +00:00
|
|
|
]);
|
2019-09-09 09:08:54 +00:00
|
|
|
yield put(successFetchingWidgetCards(widgetCards.cards));
|
|
|
|
|
} catch (err) {
|
2019-09-27 16:05:33 +00:00
|
|
|
yield put({ type: ReduxActionErrorTypes.FETCH_WIDGET_CARDS_ERROR, err });
|
2019-08-21 12:49:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* fetchWidgetCardsSaga() {
|
2019-09-13 11:59:45 +00:00
|
|
|
yield takeLatest(ReduxActionTypes.FETCH_WIDGET_CARDS, fetchWidgetCards);
|
2019-09-09 09:08:54 +00:00
|
|
|
}
|