2019-08-29 11:22:09 +00:00
|
|
|
// import CanvasWidgetsNormalizer from "../normalizers/CanvasWidgetsNormalizer"
|
2019-08-21 12:49:16 +00:00
|
|
|
import { ActionTypes, ReduxAction } from "../constants/ActionConstants"
|
|
|
|
|
import WidgetCardsPaneApi, { WidgetCardsPaneResponse, WidgetCardsPaneRequest } from "../api/WidgetCardsPaneApi"
|
2019-08-26 12:41:21 +00:00
|
|
|
import { successFetchingWidgetCards } from "../actions/widgetCardsPaneActions"
|
2019-08-29 11:22:09 +00:00
|
|
|
import { call, put, takeLatest } from "redux-saga/effects"
|
2019-08-21 12:49:16 +00:00
|
|
|
|
2019-08-26 12:41:21 +00:00
|
|
|
|
2019-08-21 12:49:16 +00:00
|
|
|
export function* fetchWidgetCards(widgetCardsRequestAction: ReduxAction<WidgetCardsPaneRequest>) {
|
|
|
|
|
try {
|
|
|
|
|
const widgetCards: WidgetCardsPaneResponse = yield call(WidgetCardsPaneApi.fetchWidgetCards)
|
2019-08-26 12:41:21 +00:00
|
|
|
yield put(successFetchingWidgetCards(widgetCards.cards))
|
2019-08-21 12:49:16 +00:00
|
|
|
} catch(err) {
|
|
|
|
|
yield put({ type: ActionTypes.ERROR_FETCHING_WIDGET_CARDS, err})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* fetchWidgetCardsSaga() {
|
|
|
|
|
yield takeLatest(ActionTypes.FETCH_WIDGET_CARDS, fetchWidgetCards)
|
|
|
|
|
}
|