PromucFlow_constructor/app/client/src/sagas/CollectionSagas.ts
Hetu Nandu af3b5d212f fix: ui fixes and type defination fixes
- avoid using any or undefined types in the code
- fix ui issues for api home screen
- update naming convensions
- remove unwanted code
- use color variables
2020-04-14 12:34:14 +00:00

40 lines
1.1 KiB
TypeScript

import { call, takeLatest, put, all } from "redux-saga/effects";
import {
ReduxActionTypes,
ReduxActionErrorTypes,
} from "constants/ReduxActionConstants";
import { validateResponse } from "sagas/ErrorSagas";
import ImportedCollectionsApi from "api/CollectionApi";
import { ImportedCollections } from "constants/collectionsConstants";
export function* fetchImportedCollectionsSaga() {
try {
const response: ImportedCollections = yield call(
ImportedCollectionsApi.fetchImportedCollections,
);
const isValidResponse = yield validateResponse(response);
if (isValidResponse) {
yield put({
type: ReduxActionTypes.FETCH_IMPORTED_COLLECTIONS_SUCCESS,
payload: response.data,
});
}
} catch (error) {
yield put({
type: ReduxActionErrorTypes.FETCH_IMPORTED_COLLECTIONS_ERROR,
payload: {
error,
},
});
}
}
export default function* importedCollectionsSagas() {
yield all([
takeLatest(
ReduxActionTypes.FETCH_IMPORTED_COLLECTIONS_INIT,
fetchImportedCollectionsSaga,
),
]);
}