fix(frontend): try not to render broken rottentomatoes data

pull/401/head
sct 4 years ago
parent 816fec1a83
commit a0c5608aa0

@ -397,34 +397,36 @@ const MovieDetails: React.FC<MovieDetailsProps> = ({ movie }) => {
<div className="bg-gray-900 rounded-lg shadow border border-gray-800"> <div className="bg-gray-900 rounded-lg shadow border border-gray-800">
{(data.voteCount > 0 || ratingData) && ( {(data.voteCount > 0 || ratingData) && (
<div className="flex px-4 py-2 border-b border-gray-800 last:border-b-0 items-center justify-center"> <div className="flex px-4 py-2 border-b border-gray-800 last:border-b-0 items-center justify-center">
{ratingData?.criticsRating && ( {ratingData?.criticsRating &&
<> (ratingData?.criticsScore ?? 0) > 0 && (
<span className="text-sm"> <>
{ratingData.criticsRating === 'Rotten' ? ( <span className="text-sm">
<RTRotten className="w-6 mr-1" /> {ratingData.criticsRating === 'Rotten' ? (
) : ( <RTRotten className="w-6 mr-1" />
<RTFresh className="w-6 mr-1" /> ) : (
)} <RTFresh className="w-6 mr-1" />
</span> )}
<span className="text-gray-400 text-sm mr-4 last:mr-0"> </span>
{ratingData.criticsScore}% <span className="text-gray-400 text-sm mr-4 last:mr-0">
</span> {ratingData.criticsScore}%
</> </span>
)} </>
{ratingData?.audienceRating && ( )}
<> {ratingData?.audienceRating &&
<span className="text-sm"> (ratingData?.audienceScore ?? 0) > 0 && (
{ratingData.audienceRating === 'Spilled' ? ( <>
<RTAudRotten className="w-6 mr-1" /> <span className="text-sm">
) : ( {ratingData.audienceRating === 'Spilled' ? (
<RTAudFresh className="w-6 mr-1" /> <RTAudRotten className="w-6 mr-1" />
)} ) : (
</span> <RTAudFresh className="w-6 mr-1" />
<span className="text-gray-400 text-sm mr-4 last:mr-0"> )}
{ratingData.audienceScore}% </span>
</span> <span className="text-gray-400 text-sm mr-4 last:mr-0">
</> {ratingData.audienceScore}%
)} </span>
</>
)}
{data.voteCount > 0 && ( {data.voteCount > 0 && (
<> <>
<span className="text-sm"> <span className="text-sm">

@ -406,34 +406,36 @@ const TvDetails: React.FC<TvDetailsProps> = ({ tv }) => {
<div className="bg-gray-900 rounded-lg shadow border border-gray-800"> <div className="bg-gray-900 rounded-lg shadow border border-gray-800">
{(data.voteCount > 0 || ratingData) && ( {(data.voteCount > 0 || ratingData) && (
<div className="flex px-4 py-2 border-b border-gray-800 last:border-b-0 items-center justify-center"> <div className="flex px-4 py-2 border-b border-gray-800 last:border-b-0 items-center justify-center">
{ratingData?.criticsRating && ( {ratingData?.criticsRating &&
<> (ratingData?.criticsScore ?? 0) > 0 && (
<span className="text-sm"> <>
{ratingData.criticsRating === 'Rotten' ? ( <span className="text-sm">
<RTRotten className="w-6 mr-1" /> {ratingData.criticsRating === 'Rotten' ? (
) : ( <RTRotten className="w-6 mr-1" />
<RTFresh className="w-6 mr-1" /> ) : (
)} <RTFresh className="w-6 mr-1" />
</span> )}
<span className="text-gray-400 text-sm mr-4 last:mr-0"> </span>
{ratingData.criticsScore}% <span className="text-gray-400 text-sm mr-4 last:mr-0">
</span> {ratingData.criticsScore}%
</> </span>
)} </>
{ratingData?.audienceRating && ( )}
<> {ratingData?.audienceRating &&
<span className="text-sm"> (ratingData?.audienceScore ?? 0) > 0 && (
{ratingData.audienceRating === 'Spilled' ? ( <>
<RTAudRotten className="w-6 mr-1" /> <span className="text-sm">
) : ( {ratingData.audienceRating === 'Spilled' ? (
<RTAudFresh className="w-6 mr-1" /> <RTAudRotten className="w-6 mr-1" />
)} ) : (
</span> <RTAudFresh className="w-6 mr-1" />
<span className="text-gray-400 text-sm mr-4 last:mr-0"> )}
{ratingData.audienceScore}% </span>
</span> <span className="text-gray-400 text-sm mr-4 last:mr-0">
</> {ratingData.audienceScore}%
)} </span>
</>
)}
{data.voteCount > 0 && ( {data.voteCount > 0 && (
<> <>
<span className="text-sm"> <span className="text-sm">

Loading…
Cancel
Save