1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-28 14:16:41 +07:00
This commit is contained in:
Fedor Katurov 2021-03-22 15:56:35 +07:00
parent 9745b895f1
commit 11fd582453
23 changed files with 328 additions and 101 deletions

View file

@ -1,8 +1,8 @@
import { takeLeading, call, put } from 'redux-saga/effects';
import { labGetList, labSetList } from '~/redux/lab/actions';
import { labGetList, labSetList, labSetStats } from '~/redux/lab/actions';
import { LAB_ACTIONS } from '~/redux/lab/constants';
import { Unwrap } from '~/redux/types';
import { getLabNodes } from '~/redux/lab/api';
import { getLabNodes, getLabStats } from '~/redux/lab/api';
function* getList({ after = '' }: ReturnType<typeof labGetList>) {
try {
@ -16,6 +16,19 @@ function* getList({ after = '' }: ReturnType<typeof labGetList>) {
}
}
function* getStats() {
try {
yield put(labSetStats({ is_loading: true }));
const { heroes, tags }: Unwrap<typeof getLabStats> = yield call(getLabStats);
yield put(labSetStats({ heroes, tags }));
} catch (error) {
yield put(labSetStats({ error: error.message }));
} finally {
yield put(labSetStats({ is_loading: false }));
}
}
export default function* labSaga() {
yield takeLeading(LAB_ACTIONS.GET_LIST, getList);
yield takeLeading(LAB_ACTIONS.GET_STATS, getStats);
}