mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-28 14:16:41 +07:00
#23 lab stats
This commit is contained in:
parent
9745b895f1
commit
11fd582453
23 changed files with 328 additions and 101 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue