import React, { useMemo } from 'react'; import PropTypes from 'prop-types'; import { Avatar, Badge, Icon } from '@openedx/paragon'; import { Question } from '@openedx/paragon/icons'; import classNames from 'classnames'; import { useSelector } from 'react-redux'; import { getConfig } from '@edx/frontend-platform'; import { useIntl } from '@edx/frontend-platform/i18n'; import { AvatarOutlineAndLabelColors, ThreadType } from '../../../data/constants'; import { AuthorLabel } from '../../common'; import { useAlertBannerVisible } from '../../data/hooks'; import { selectAuthorAvatar } from '../data/selectors'; import messages from './messages'; export const PostAvatar = React.memo(({ author, postType, authorLabel, fromPostLink, read, postUsers, }) => { const outlineColor = AvatarOutlineAndLabelColors[authorLabel]; const authorAvatars = useSelector(selectAuthorAvatar(author)); const avatarSize = useMemo(() => { let size = '2rem'; if (postType === ThreadType.DISCUSSION && !fromPostLink) { size = '2rem'; } else if (postType === ThreadType.QUESTION) { size = '1.5rem'; } return size; }, [postType]); const avatarSpacing = useMemo(() => { let spacing = 'mr-3 '; if (postType === ThreadType.DISCUSSION && fromPostLink) { spacing += 'pt-2 ml-0.5'; } else if (postType === ThreadType.DISCUSSION) { spacing += 'ml-0.5 mt-0.5'; } return spacing; }, [postType]); const profileImage = getConfig()?.ENABLE_PROFILE_IMAGE === 'true' ? Object.values(postUsers ?? {})[0]?.profile?.image : null; return (