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

hero slider

This commit is contained in:
Fedor Katurov 2019-10-24 15:44:40 +07:00
parent a9da7e8cef
commit 5cd5941be0
12 changed files with 266 additions and 14 deletions

View file

@ -7,6 +7,11 @@ export const flowSetNodes = (nodes: IFlowState['nodes']) => ({
type: FLOW_ACTIONS.SET_NODES,
});
export const flowSetHeroes = (heroes: IFlowState['heroes']) => ({
heroes,
type: FLOW_ACTIONS.SET_HEROES,
});
export const flowSetCellView = (id: INode['id'], flow: INode['flow']) => ({
type: FLOW_ACTIONS.SET_CELL_VIEW,
id,

View file

@ -3,5 +3,6 @@ const prefix = 'FLOW.';
export const FLOW_ACTIONS = {
GET_FLOW: `${prefix}GET_FLOW`,
SET_NODES: `${prefix}SET_NODES`,
SET_HEROES: `${prefix}SET_HEROES`,
SET_CELL_VIEW: `${prefix}SET_CELL_VIEW`,
};

View file

@ -1,11 +1,15 @@
import assocPath from 'ramda/es/assocPath';
import { FLOW_ACTIONS } from './constants';
import { flowSetNodes } from './actions';
import { flowSetNodes, flowSetHeroes } from './actions';
import { IFlowState } from './reducer';
const setNodes = (state: IFlowState, { nodes }: ReturnType<typeof flowSetNodes>) =>
assocPath(['nodes'], nodes, state);
const setHeroes = (state: IFlowState, { heroes }: ReturnType<typeof flowSetHeroes>) =>
assocPath(['heroes'], heroes, state);
export const FLOW_HANDLERS = {
[FLOW_ACTIONS.SET_NODES]: setNodes,
[FLOW_ACTIONS.SET_HEROES]: setHeroes,
};

View file

@ -5,11 +5,13 @@ import { FLOW_HANDLERS } from './handlers';
export type IFlowState = Readonly<{
is_loading: boolean;
nodes: INode[];
heroes: Partial<INode>[];
error: IError;
}>;
const INITIAL_STATE: IFlowState = {
nodes: [],
heroes: [],
is_loading: false,
error: null,
};

View file

@ -2,23 +2,29 @@ import { takeLatest, call, put, select } from 'redux-saga/effects';
import { REHYDRATE } from 'redux-persist';
import { FLOW_ACTIONS } from './constants';
import { getNodes } from '../node/api';
import { flowSetNodes, flowSetCellView } from './actions';
import { flowSetNodes, flowSetCellView, flowSetHeroes } from './actions';
import { IResultWithStatus, INode } from '../types';
import { selectFlowNodes } from './selectors';
import { reqWrapper } from '../auth/sagas';
import { postCellView } from './api';
import { IFlowState } from './reducer';
function* onGetFlow() {
const {
data: { nodes = null },
}: IResultWithStatus<{ nodes: INode[] }> = yield call(getNodes, {});
data: { nodes = null, heroes = null },
}: IResultWithStatus<{ nodes: IFlowState['nodes']; heroes: IFlowState['heroes'] }> = yield call(
getNodes,
{}
);
if (!nodes || !nodes.length) {
yield put(flowSetNodes([]));
yield put(flowSetHeroes([]));
return;
}
yield put(flowSetNodes(nodes));
yield put(flowSetHeroes(heroes));
}
function* onSetCellView({ id, flow }: ReturnType<typeof flowSetCellView>) {