feat(ui): added content ratings for tv shows and movie ratings (#878)

This commit is contained in:
Danshil Mungur
2021-02-09 12:24:07 +04:00
committed by GitHub
parent 4e03c1efcf
commit c8b2a57721
8 changed files with 138 additions and 6 deletions

View File

@@ -133,6 +133,26 @@ const TvDetails: React.FC<TvDetailsProps> = ({ tv }) => {
revalidate();
};
const seriesAttributes: React.ReactNode[] = [];
if (
data.contentRatings.results.length &&
data.contentRatings.results.find(
(r) => r.iso_3166_1 === 'US' || data.contentRatings.results[0].rating
)
) {
seriesAttributes.push(
<span className="p-0.5 py-0 border rounded-md">
{data.contentRatings.results.find((r) => r.iso_3166_1 === 'US')
?.rating || data.contentRatings.results[0].rating}
</span>
);
}
if (data.genres.length) {
seriesAttributes.push(data.genres.map((g) => g.name).join(', '));
}
const isComplete =
data.seasons.filter((season) => season.seasonNumber !== 0).length <=
(
@@ -392,7 +412,13 @@ const TvDetails: React.FC<TvDetailsProps> = ({ tv }) => {
)}
</h1>
<span className="mt-1 text-xs lg:text-base lg:mt-0">
{data.genres.map((g) => g.name).join(', ')}
{seriesAttributes
.map((t, k) => <span key={k}>{t}</span>)
.reduce((prev, curr) => (
<>
{prev} | {curr}
</>
))}
</span>
</div>
<div className="flex flex-wrap justify-center flex-shrink-0 mt-4 sm:flex-nowrap sm:justify-end lg:mt-0">