From 52cf6c4abdf4e4e6a82ee631712ffcda68d59fa2 Mon Sep 17 00:00:00 2001 From: Jenni Nurmi Date: Thu, 7 Feb 2019 15:00:16 +0200 Subject: [PATCH] Use UserDisplayName in Reviews --- src/components/Reviews/Reviews.example.js | 15 ++++++++++++++- src/components/Reviews/Reviews.js | 10 ++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/components/Reviews/Reviews.example.js b/src/components/Reviews/Reviews.example.js index aedd5610..f57eadd1 100644 --- a/src/components/Reviews/Reviews.example.js +++ b/src/components/Reviews/Reviews.example.js @@ -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 }) } ), ], }, diff --git a/src/components/Reviews/Reviews.js b/src/components/Reviews/Reviews.js index 8e8e40b9..9233b6b7 100644 --- a/src/components/Reviews/Reviews.js +++ b/src/components/Reviews/Reviews.js @@ -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 => { />

{review.attributes.content}

- {authorDisplayName(review, intl)} + {dateString}