1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00
vault-frontend/src/redux/node/reducer.ts
2019-08-25 16:10:46 +07:00

29 lines
663 B
TypeScript

import uuid from 'uuid4';
import { createReducer } from '~/utils/reducer';
import { INode } from '../types';
import { EMPTY_BLOCK, EMPTY_NODE } from './constants';
import { NODE_HANDLERS } from './handlers';
import { EMPTY_FILE } from '../uploads/constants';
export type INodeState = Readonly<{
is_loading: boolean;
editor: INode;
current: INode;
error: string;
errors: Record<string, string>;
}>;
const INITIAL_STATE: INodeState = {
editor: {
...EMPTY_NODE,
type: 'image',
blocks: [],
files: [],
},
current: null,
is_loading: false,
error: null,
errors: {},
};
export default createReducer(INITIAL_STATE, NODE_HANDLERS);