mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
added working tiny-slider!
This commit is contained in:
parent
fefec524db
commit
531bd3626a
7 changed files with 122 additions and 57 deletions
|
@ -1,8 +1,10 @@
|
|||
import { USER_ROLES } from '~/redux/auth/constants';
|
||||
import { INode, IComment, ICommentGroup } from '~/redux/types';
|
||||
import { INode, IComment, ICommentGroup, IFile } from '~/redux/types';
|
||||
import { IUser } from '~/redux/auth/types';
|
||||
import path from 'ramda/es/path';
|
||||
import { NODE_TYPES } from '~/redux/node/constants';
|
||||
import { useMemo } from 'react';
|
||||
import { UPLOAD_TYPES } from '~/redux/uploads/constants';
|
||||
|
||||
export const canEditNode = (node: Partial<INode>, user: Partial<IUser>): boolean =>
|
||||
path(['role'], user) === USER_ROLES.ADMIN ||
|
||||
|
@ -19,3 +21,11 @@ export const canStarNode = (node: Partial<INode>, user: Partial<IUser>): boolean
|
|||
node.type === NODE_TYPES.IMAGE &&
|
||||
path(['role'], user) &&
|
||||
path(['role'], user) === USER_ROLES.ADMIN;
|
||||
|
||||
export const useNodeImages = (node: INode): IFile[] => {
|
||||
return useMemo(
|
||||
() =>
|
||||
(node && node.files && node.files.filter(({ type }) => type === UPLOAD_TYPES.IMAGE)) || [],
|
||||
[node.files]
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue