1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

comment locking initial

This commit is contained in:
Fedor Katurov 2019-11-29 12:21:11 +07:00
parent 6eafc227da
commit 59d544c5f4
10 changed files with 139 additions and 44 deletions

View file

@ -1,5 +1,5 @@
import { USER_ROLES } from '~/redux/auth/constants';
import { INode } from '~/redux/types';
import { INode, IComment, ICommentGroup } from '~/redux/types';
import { IUser } from '~/redux/auth/types';
import path from 'ramda/es/path';
import { NODE_TYPES } from '~/redux/node/constants';
@ -8,6 +8,10 @@ export const canEditNode = (node: Partial<INode>, user: Partial<IUser>): boolean
path(['role'], user) === USER_ROLES.ADMIN ||
(path(['user', 'id'], node) && path(['user', 'id'], node) === path(['id'], user));
export const canEditComment = (comment: Partial<ICommentGroup>, user: Partial<IUser>): boolean =>
path(['role'], user) === USER_ROLES.ADMIN ||
(path(['user', 'id'], comment) && path(['user', 'id'], comment) === path(['id'], user));
export const canLikeNode = (node: Partial<INode>, user: Partial<IUser>): boolean =>
path(['role'], user) && path(['role'], user) !== USER_ROLES.GUEST;