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:
parent
f4c337b255
commit
249a9b368c
7 changed files with 117 additions and 28 deletions
11
src/utils/node.ts
Normal file
11
src/utils/node.ts
Normal 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;
|
Loading…
Add table
Add a link
Reference in a new issue