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

node edit and like buttons + actions

This commit is contained in:
Fedor Katurov 2019-10-22 12:17:45 +07:00
parent f4c337b255
commit 249a9b368c
7 changed files with 117 additions and 28 deletions

11
src/utils/node.ts Normal file
View file

@ -0,0 +1,11 @@
import { USER_ROLES } from '~/redux/auth/constants';
import { INode } from '~/redux/types';
import { IUser } from '~/redux/auth/types';
import path from 'ramda/es/path';
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 canLikeNode = (node: Partial<INode>, user: Partial<IUser>): boolean =>
path(['role'], user) && path(['role'], user) !== USER_ROLES.GUEST;