Use UserDisplayName in Reviews

This commit is contained in:
Jenni Nurmi 2019-02-07 15:00:16 +02:00
parent cde1ec2e7e
commit 52cf6c4abd
2 changed files with 16 additions and 9 deletions

View file

@ -26,7 +26,20 @@ export const WithBannedUser = {
createReview(
'review_1',
{ rating: 1 },
{ author: createUser('author_1', { banned: true, profile: null }) }
{ author: createUser('author_1', { banned: true, deleted: false, profile: null }) }
),
],
},
};
export const WithDeletedUser = {
component: Reviews,
props: {
reviews: [
createReview(
'review_1',
{ rating: 2 },
{ author: createUser('author_1', { banned: false, deleted: true, profile: null }) }
),
],
},

View file

@ -2,17 +2,11 @@ import React from 'react';
import { injectIntl, intlShape } from 'react-intl';
import { arrayOf, string } from 'prop-types';
import classNames from 'classnames';
import { Avatar, ReviewRating } from '../../components';
import { Avatar, ReviewRating, UserDisplayName } from '../../components';
import { propTypes } from '../../util/types';
import css from './Reviews.css';
const authorDisplayName = (review, intl) => {
return review.author.attributes.banned
? intl.formatMessage({ id: 'Reviews.bannedUserDisplayName' })
: review.author.attributes.profile.displayName;
};
const Review = props => {
const { review, intl } = props;
@ -30,7 +24,7 @@ const Review = props => {
/>
<p className={css.reviewContent}>{review.attributes.content}</p>
<p className={css.reviewInfo}>
{authorDisplayName(review, intl)}
<UserDisplayName user={review.author} intl={intl} />
<span className={css.separator}></span>
{dateString}
<span className={css.desktopSeparator}></span>