1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00
vault-frontend/src/components/node/NodeCommentsBlock/index.tsx
2021-03-06 13:17:39 +07:00

28 lines
943 B
TypeScript

import React, { FC } from 'react';
import { NodeNoComments } from '~/components/node/NodeNoComments';
import { NodeComments } from '~/components/node/NodeComments';
import { IComment, INode } from '~/redux/types';
import { useNodeBlocks } from '~/utils/hooks/node/useNodeBlocks';
import { useUser } from '~/utils/hooks/user/userUser';
interface IProps {
order: 'ASC' | 'DESC';
node: INode;
comments: IComment[];
count: number;
isLoading: boolean;
isLoadingComments: boolean;
}
const NodeCommentsBlock: FC<IProps> = ({ isLoading, isLoadingComments, node, comments, count }) => {
const user = useUser();
const { inline } = useNodeBlocks(node, isLoading);
return isLoading || isLoadingComments || (!comments.length && !inline) ? (
<NodeNoComments is_loading={isLoadingComments || isLoading} />
) : (
<NodeComments count={count} comments={comments} user={user} order="DESC" />
);
};
export { NodeCommentsBlock };