import React, { FC, useMemo } from 'react'; import { IComment, IFile } from '~/redux/types'; import path from 'ramda/es/path'; import { formatCommentText, getURL, getPrettyDate } from '~/utils/dom'; import { Group } from '~/components/containers/Group'; import * as styles from './styles.scss'; import { UPLOAD_TYPES } from '~/redux/uploads/constants'; import assocPath from 'ramda/es/assocPath'; import append from 'ramda/es/append'; import reduce from 'ramda/es/reduce'; import { AudioPlayer } from '~/components/media/AudioPlayer'; import classnames from 'classnames'; interface IProps { comment: IComment; } const CommentContent: FC = ({ comment }) => { const groupped = useMemo>( () => reduce( (group, file) => assocPath([file.type], append(file, group[file.type]), group), {}, comment.files ), [comment] ); return ( <> {comment.text && (
{getPrettyDate(comment.created_at)}
)} {groupped.image && groupped.image.length > 0 && (
{groupped.image.map(file => (
{file.name}
))}
{getPrettyDate(comment.created_at)}
)} {groupped.audio && groupped.audio.length > 0 && ( <> {groupped.audio.map(file => (
{getPrettyDate(comment.created_at)}
))} )} ); }; export { CommentContent }; /* {comment.text && ( )} */