From 6c80f3977a211a4070ab19d2ed043acde6882a68 Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Sun, 14 Jun 2020 14:39:12 -0600 Subject: [PATCH] Hide reviews UI in Search if no reviews available --- app/views/search/resultDetails.js | 66 +++++++++++++++++-------------- server/i18n/locales/en/ui.json | 3 ++ 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/app/views/search/resultDetails.js b/app/views/search/resultDetails.js index 82ac38b..89d17f1 100644 --- a/app/views/search/resultDetails.js +++ b/app/views/search/resultDetails.js @@ -8,21 +8,28 @@ export const resultDetails = (searchController, result, emit = () => {}) => { const { __ } = searchController.i18n; const modalId = `result_${result.uri}`; + const hasReviews = typeof result.averageRating !== 'undefined' && typeof result.numberOfReviews !== 'undefined'; + const buttonHTML = html``; const tabNames = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']; const modalContent = html`
-

Covers

+

${__('search.covers')}

${typeof result.covers === 'undefined' ? html`` : html`
@@ -55,32 +62,33 @@ export const resultDetails = (searchController, result, emit = () => {}) => { }
-

${__('interaction.average_rating')}

- ${starRating(result.averageRating)} + ${!hasReviews + ? html`

${__('search.no_reviews')}

` + : html`

${__('interaction.average_rating')}

+ ${starRating(result.averageRating)} -
- - ${result.reviews.map(review => { - return reviewCard(searchController, review); - })} + ${(typeof result.reviews !== 'undefined' && Array.isArray(result.reviews) ? result.reviews : []).map(review => { + return reviewCard(searchController, review); + })}` + }