import React from 'react'; import PropTypes from 'prop-types'; import { useSelector } from 'react-redux'; import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; import { Avatar, Badge, Icon } from '@edx/paragon'; import { Help } from '../../../components/icons'; import { AvatarBorderAndLabelColors, ThreadType } from '../../../data/constants'; import { ActionsDropdown, AuthorLabel } from '../../common'; import { selectAuthorAvatars } from '../data/selectors'; import messages from './messages'; import { postShape } from './proptypes'; export function PostAvatar({ post, authorLabel, fromPostLink }) { const authorAvatars = useSelector(selectAuthorAvatars(post.author)); const borderColor = AvatarBorderAndLabelColors[authorLabel]; return (
{post.type === ThreadType.QUESTION && ( )}
); } PostAvatar.propTypes = { post: postShape.isRequired, authorLabel: PropTypes.string, fromPostLink: PropTypes.bool, }; PostAvatar.defaultProps = { authorLabel: null, fromPostLink: false, }; function PostHeader({ intl, post, preview, actionHandlers, }) { const showAnsweredBadge = preview && post.hasEndorsed && post.type === ThreadType.QUESTION; const authorLabelColor = AvatarBorderAndLabelColors[post.authorLabel]; return (
{preview ? (
{post.title}
{showAnsweredBadge && {intl.formatMessage(messages.answered)}}
) :

{post.title}

}
{!preview && (
)}
); } PostHeader.propTypes = { intl: intlShape.isRequired, post: postShape.isRequired, preview: PropTypes.bool, actionHandlers: PropTypes.objectOf(PropTypes.func).isRequired, }; PostHeader.defaultProps = { preview: false, }; export default injectIntl(PostHeader);