- 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
40 lines
1.1 KiB
TypeScript
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,
|
|
),
|
|
]);
|
|
}
|