1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-26 13:26:40 +07:00

added saga for boris load stats

This commit is contained in:
Fedor Katurov 2020-06-08 14:01:20 +07:00
parent f8b2b3707b
commit 29c3b8a26f
8 changed files with 83 additions and 7 deletions

View file

@ -0,0 +1,11 @@
import { IBorisState } from './reducer';
import { BORIS_ACTIONS } from './constants';
export const borisSet = (state: Partial<IBorisState>) => ({
type: BORIS_ACTIONS.SET_BORIS,
state,
});
export const borisLoadStats = () => ({
type: BORIS_ACTIONS.LOAD_STATS,
});

View file

@ -0,0 +1,6 @@
const prefix = `BORIS.`;
export const BORIS_ACTIONS = {
SET_BORIS: `${prefix}SET_BORIS`,
LOAD_STATS: `${prefix}LOAD_STATS`,
};

View file

@ -1 +1,11 @@
export const BORIS_HANDLERS = {};
import { IBorisState } from './reducer';
import { BORIS_ACTIONS } from './constants';
const borisSet = (current: IBorisState, { state }: ReturnType<typeof borisSet>) => ({
...current,
...state,
});
export const BORIS_HANDLERS = {
[BORIS_ACTIONS.SET_BORIS]: borisSet,
};

View file

@ -11,12 +11,14 @@ export type IBorisState = Readonly<{
stats: {
git: IStatGitRow[];
};
is_loading: boolean;
}>;
const BORIS_INITIAL_STATE: IBorisState = {
stats: {
git: [],
},
is_loading: false,
};
export default createReducer(BORIS_INITIAL_STATE, BORIS_HANDLERS);

View file

@ -1 +1,12 @@
export default function* borisSaga() {}
import { takeLatest, put } from 'redux-saga/effects';
import { BORIS_ACTIONS } from './constants';
import { borisSet } from './actions';
function* loadStats() {
yield put(borisSet({ is_loading: true }));
yield put(borisSet({ is_loading: false }));
}
export default function* borisSaga() {
yield takeLatest(BORIS_ACTIONS.LOAD_STATS, loadStats);
}

View file

@ -0,0 +1,4 @@
import { IState } from '../store';
export const selectBoris = (state: IState) => state.boris;
export const selectBorisStats = (state: IState) => state.boris.stats;