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

107 lines
2.4 KiB
TypeScript

import { INode, IValidationErrors, IComment, ITag, IFile } from '../types';
import { NODE_ACTIONS, NODE_TYPES } from './constants';
import { INodeState } from './reducer';
export const nodeSave = (node: INode) => ({
node,
type: NODE_ACTIONS.SAVE,
});
export const nodeSetSaveErrors = (errors: IValidationErrors) => ({
errors,
type: NODE_ACTIONS.SET_SAVE_ERRORS,
});
export const nodeGotoNode = (id: number, node_type: INode['type']) => ({
id,
node_type,
type: NODE_ACTIONS.GOTO_NODE,
});
export const nodeLoadNode = (id: number, order?: 'ASC' | 'DESC') => ({
id,
order,
type: NODE_ACTIONS.LOAD_NODE,
});
export const nodeSetLoading = (is_loading: INodeState['is_loading']) => ({
is_loading,
type: NODE_ACTIONS.SET_LOADING,
});
export const nodeSetLoadingComments = (is_loading_comments: INodeState['is_loading_comments']) => ({
is_loading_comments,
type: NODE_ACTIONS.SET_LOADING_COMMENTS,
});
export const nodeSetCurrent = (current: INodeState['current']) => ({
current,
type: NODE_ACTIONS.SET_CURRENT,
});
export const nodePostComment = (id: number) => ({
id,
type: NODE_ACTIONS.POST_COMMENT,
});
export const nodeSetSendingComment = (is_sending_comment: boolean) => ({
is_sending_comment,
type: NODE_ACTIONS.SET_SENDING_COMMENT,
});
export const nodeSetComments = (comments: IComment[]) => ({
comments,
type: NODE_ACTIONS.SET_COMMENTS,
});
export const nodeSetRelated = (related: INodeState['related']) => ({
related,
type: NODE_ACTIONS.SET_RELATED,
});
export const nodeSetCommentData = (id: number, comment: IComment) => ({
id,
comment,
type: NODE_ACTIONS.SET_COMMENT_DATA,
});
export const nodeUpdateTags = (id: INode['id'], tags: string[]) => ({
type: NODE_ACTIONS.UPDATE_TAGS,
id,
tags,
});
export const nodeSetTags = (tags: ITag[]) => ({
type: NODE_ACTIONS.SET_TAGS,
tags,
});
export const nodeCreate = (node_type: INode['type']) => ({
type: NODE_ACTIONS.CREATE,
node_type,
});
export const nodeEdit = (id: INode['id']) => ({
type: NODE_ACTIONS.EDIT,
id,
});
export const nodeLike = (id: INode['id']) => ({
type: NODE_ACTIONS.LIKE,
id,
});
export const nodeStar = (id: INode['id']) => ({
type: NODE_ACTIONS.STAR,
id,
});
export const nodeSetEditor = (editor: INode) => ({
type: NODE_ACTIONS.SET_EDITOR,
editor,
});
export const nodeSetCoverImage = (current_cover_image: IFile) => ({
type: NODE_ACTIONS.SET_COVER_IMAGE,
current_cover_image,
});