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:
parent
f8b2b3707b
commit
29c3b8a26f
8 changed files with 83 additions and 7 deletions
11
src/redux/boris/actions.ts
Normal file
11
src/redux/boris/actions.ts
Normal 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,
|
||||
});
|
6
src/redux/boris/constants.ts
Normal file
6
src/redux/boris/constants.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
const prefix = `BORIS.`;
|
||||
|
||||
export const BORIS_ACTIONS = {
|
||||
SET_BORIS: `${prefix}SET_BORIS`,
|
||||
LOAD_STATS: `${prefix}LOAD_STATS`,
|
||||
};
|
|
@ -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,
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
4
src/redux/boris/selectors.ts
Normal file
4
src/redux/boris/selectors.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
import { IState } from '../store';
|
||||
|
||||
export const selectBoris = (state: IState) => state.boris;
|
||||
export const selectBorisStats = (state: IState) => state.boris.stats;
|
Loading…
Add table
Add a link
Reference in a new issue