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/NodeComments/index.tsx
2019-10-15 14:46:26 +07:00

29 lines
718 B
TypeScript

import React, { FC, useMemo } from 'react';
import { Comment } from '../Comment';
import { Filler } from '~/components/containers/Filler';
import * as styles from './styles.scss';
import { ICommentGroup, IComment } from '~/redux/types';
import { groupCommentsByUser } from '~/utils/fn';
interface IProps {
comments?: IComment[];
}
const NodeComments: FC<IProps> = ({ comments }) => {
const groupped: ICommentGroup[] = useMemo(() => comments.reduce(groupCommentsByUser, []), [
comments,
]);
return (
<div className={styles.wrap}>
{groupped.map(group => (
<Comment key={group.ids.join()} comment_group={group} />
))}
<Filler />
</div>
);
};
export { NodeComments };