import {useState} from 'react'; import {__} from '@wordpress/i18n'; import {Attributes, CommentData} from '../../../types'; import './styles.scss'; export default function CampaignCommentCard({attributes, data}: {attributes: Attributes; data: CommentData}) { const [fullComment, setFullComment] = useState(false); const {comment, date, donorName, avatar} = data; const {commentLength, showAvatar, showDate, showName, readMoreText = __('Read More', 'give')} = attributes; const truncatedComment = comment.slice(0, commentLength) + (comment.length > commentLength ? '...' : ''); return (
{showAvatar && (
{__('Donor
)}
{showName &&

{donorName}

} {showDate &&

{date}

}

{fullComment ? comment : truncatedComment}

{comment?.length > commentLength && !fullComment && ( )}
); }