From a0c5608aa0b6c7a4294300589efa9a662163ce48 Mon Sep 17 00:00:00 2001 From: sct Date: Sat, 19 Dec 2020 13:39:48 +0900 Subject: [PATCH] fix(frontend): try not to render broken rottentomatoes data --- src/components/MovieDetails/index.tsx | 58 ++++++++++++++------------- src/components/TvDetails/index.tsx | 58 ++++++++++++++------------- 2 files changed, 60 insertions(+), 56 deletions(-) diff --git a/src/components/MovieDetails/index.tsx b/src/components/MovieDetails/index.tsx index 9e2f967e8..658a3d9a8 100644 --- a/src/components/MovieDetails/index.tsx +++ b/src/components/MovieDetails/index.tsx @@ -397,34 +397,36 @@ const MovieDetails: React.FC = ({ movie }) => {
{(data.voteCount > 0 || ratingData) && (
- {ratingData?.criticsRating && ( - <> - - {ratingData.criticsRating === 'Rotten' ? ( - - ) : ( - - )} - - - {ratingData.criticsScore}% - - - )} - {ratingData?.audienceRating && ( - <> - - {ratingData.audienceRating === 'Spilled' ? ( - - ) : ( - - )} - - - {ratingData.audienceScore}% - - - )} + {ratingData?.criticsRating && + (ratingData?.criticsScore ?? 0) > 0 && ( + <> + + {ratingData.criticsRating === 'Rotten' ? ( + + ) : ( + + )} + + + {ratingData.criticsScore}% + + + )} + {ratingData?.audienceRating && + (ratingData?.audienceScore ?? 0) > 0 && ( + <> + + {ratingData.audienceRating === 'Spilled' ? ( + + ) : ( + + )} + + + {ratingData.audienceScore}% + + + )} {data.voteCount > 0 && ( <> diff --git a/src/components/TvDetails/index.tsx b/src/components/TvDetails/index.tsx index 7da4771c2..f9942c9b8 100644 --- a/src/components/TvDetails/index.tsx +++ b/src/components/TvDetails/index.tsx @@ -406,34 +406,36 @@ const TvDetails: React.FC = ({ tv }) => {
{(data.voteCount > 0 || ratingData) && (
- {ratingData?.criticsRating && ( - <> - - {ratingData.criticsRating === 'Rotten' ? ( - - ) : ( - - )} - - - {ratingData.criticsScore}% - - - )} - {ratingData?.audienceRating && ( - <> - - {ratingData.audienceRating === 'Spilled' ? ( - - ) : ( - - )} - - - {ratingData.audienceScore}% - - - )} + {ratingData?.criticsRating && + (ratingData?.criticsScore ?? 0) > 0 && ( + <> + + {ratingData.criticsRating === 'Rotten' ? ( + + ) : ( + + )} + + + {ratingData.criticsScore}% + + + )} + {ratingData?.audienceRating && + (ratingData?.audienceScore ?? 0) > 0 && ( + <> + + {ratingData.audienceRating === 'Spilled' ? ( + + ) : ( + + )} + + + {ratingData.audienceScore}% + + + )} {data.voteCount > 0 && ( <>