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

#23 added comment_count and last_seen to lab

This commit is contained in:
Fedor Katurov 2021-03-24 17:11:37 +07:00
parent 5f938cfa92
commit e2d1b660cc
6 changed files with 77 additions and 20 deletions

View file

@ -1,21 +1,35 @@
import React, { FC } from 'react';
import React, { FC, useMemo } from 'react';
import { INode } from '~/redux/types';
import { useNodeBlocks } from '~/utils/hooks/node/useNodeBlocks';
import styles from './styles.module.scss';
import { LabBottomPanel } from '~/components/lab/LabBottomPanel';
import { isAfter, parseISO } from 'date-fns';
interface IProps {
node: INode;
lastSeen: string | null;
isLoading?: boolean;
commentCount: number;
}
const LabNode: FC<IProps> = ({ node, isLoading }) => {
const LabNode: FC<IProps> = ({ node, isLoading, lastSeen, commentCount }) => {
const { lab } = useNodeBlocks(node, false);
const hasNewComments = useMemo(
() =>
!!node.commented_at && !!lastSeen && isAfter(parseISO(node.commented_at), parseISO(lastSeen)),
[node.commented_at, lastSeen]
);
return (
<div className={styles.wrap}>
{lab}
<LabBottomPanel node={node} isLoading={!!isLoading} />
<LabBottomPanel
node={node}
isLoading={!!isLoading}
hasNewComments={hasNewComments}
commentCount={commentCount}
/>
</div>
);
};