1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 21:06:42 +07:00

added error display

This commit is contained in:
Fedor Katurov 2020-10-23 17:50:19 +07:00
parent b4d55a49ba
commit 7d09eb26f5
7 changed files with 45 additions and 4 deletions

View file

@ -70,7 +70,7 @@ export const nodeSetRelated = (related: INodeState['related']) => ({
type: NODE_ACTIONS.SET_RELATED,
});
export const nodeSetCommentData = (id: number, comment: IComment) => ({
export const nodeSetCommentData = (id: number, comment: Partial<IComment>) => ({
id,
comment,
type: NODE_ACTIONS.SET_COMMENT_DATA,

View file

@ -110,6 +110,7 @@ export const EMPTY_COMMENT: IComment = {
temp_ids: [],
is_private: false,
user: null,
error: '',
};
export const NODE_EDITORS = {

View file

@ -49,7 +49,16 @@ const setRelated = (state: INodeState, { related }: ReturnType<typeof nodeSetRel
const setCommentData = (
state: INodeState,
{ id, comment }: ReturnType<typeof nodeSetCommentData>
) => assocPath(['comment_data', id], comment, state);
) => ({
...state,
comment_data: {
...state.comment_data,
[id]: {
...(state.comment_data[id] || {}),
...comment,
},
},
})
const setTags = (state: INodeState, { tags }: ReturnType<typeof nodeSetTags>) =>
assocPath(['current', 'tags'], tags, state);

View file

@ -207,7 +207,7 @@ function* onPostComment({ id }: ReturnType<typeof nodePostComment>) {
yield put(nodeSetSendingComment(false));
if (error || !comment) {
return yield put(nodeSetSaveErrors({ error: error || ERRORS.EMPTY_RESPONSE }));
return yield put(nodeSetCommentData(id, { error }));
}
const { current: current_node } = yield select(selectNode);

View file

@ -146,6 +146,7 @@ export interface IComment {
files: IFile[];
is_private: boolean;
user: IUser;
error?: string;
created_at?: string;
update_at?: string;