import React from 'react'; import PropTypes from 'prop-types'; import { Collapse } from 'reactstrap'; import { RendererOptions } from '~/services/renderer/renderer'; import { useRendererConfig } from '~/stores/context'; import { Comment } from './Comment'; class ReplayComments extends React.PureComponent { constructor() { super(); this.state = { isOlderRepliesShown: false, }; this.toggleOlderReplies = this.toggleOlderReplies.bind(this); } toggleOlderReplies() { this.setState({ isOlderRepliesShown: !this.state.isOlderRepliesShown }); } renderReply(reply) { return (
); } render() { const { config } = this.props; const isAllReplyShown = config.isAllReplyShown || false; const replyList = this.props.replyList; if (isAllReplyShown) { return ( {replyList.map((reply) => { return this.renderReply(reply); })} ); } const areThereHiddenReplies = (replyList.length > 2); const { isOlderRepliesShown } = this.state; const toggleButtonIconName = isOlderRepliesShown ? 'icon-arrow-up' : 'icon-options-vertical'; const toggleButtonIcon = ; const toggleButtonLabel = isOlderRepliesShown ? '' : 'more'; const shownReplies = replyList.slice(replyList.length - 2, replyList.length); const hiddenReplies = replyList.slice(0, replyList.length - 2); const hiddenElements = hiddenReplies.map((reply) => { return this.renderReply(reply); }); const shownElements = shownReplies.map((reply) => { return this.renderReply(reply); }); return ( {areThereHiddenReplies && (
{hiddenElements}
)} {shownElements}
); } } ReplayComments.propTypes = { rendererOptions: PropTypes.instanceOf(RendererOptions).isRequired, deleteBtnClicked: PropTypes.func.isRequired, isReadOnly: PropTypes.bool.isRequired, replyList: PropTypes.array, }; const ReplayCommentsWrapperFC = (props) => { const { data: config } = useRendererConfig(); return ; }; export default ReplayCommentsWrapperFC;