mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
29 lines
718 B
TypeScript
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 };
|