fix(frontend): fix tv shows failing to open when firstAirDate is undefined

fix #347
This commit is contained in:
sct
2020-12-17 01:14:12 +00:00
parent 647d5efb09
commit c21fa5b535
3 changed files with 9 additions and 5 deletions

View File

@@ -56,7 +56,7 @@ export interface TvDetails {
profilePath?: string; profilePath?: string;
}[]; }[];
episodeRunTime: number[]; episodeRunTime: number[];
firstAirDate: string; firstAirDate?: string;
genres: Genre[]; genres: Genre[];
homepage: string; homepage: string;
inProduction: boolean; inProduction: boolean;

View File

@@ -21,7 +21,7 @@ interface TitleCardProps {
id: number; id: number;
image?: string; image?: string;
summary?: string; summary?: string;
year: string; year?: string;
title: string; title: string;
userScore: number; userScore: number;
mediaType: MediaType; mediaType: MediaType;
@@ -169,7 +169,7 @@ const TitleCard: React.FC<TitleCardProps> = ({
> >
<div className="absolute bottom-0 w-full left-0 right-0"> <div className="absolute bottom-0 w-full left-0 right-0">
<div className="px-2 text-white"> <div className="px-2 text-white">
<div className="text-sm">{year}</div> {year && <div className="text-sm">{year}</div>}
<h1 className="text-xl leading-tight whitespace-normal"> <h1 className="text-xl leading-tight whitespace-normal">
{title} {title}

View File

@@ -227,8 +227,12 @@ const TvDetails: React.FC<TvDetailsProps> = ({ tv }) => {
)} )}
</div> </div>
<h1 className="text-2xl md:text-4xl"> <h1 className="text-2xl md:text-4xl">
{data.name}{' '} <span>{data.name}</span>
<span className="text-2xl">({data.firstAirDate.slice(0, 4)})</span> {data.firstAirDate && (
<span className="text-2xl ml-2">
({data.firstAirDate.slice(0, 4)})
</span>
)}
</h1> </h1>
<span className="text-xs md:text-base mt-1 md:mt-0"> <span className="text-xs md:text-base mt-1 md:mt-0">
{data.genres.map((g) => g.name).join(', ')} {data.genres.map((g) => g.name).join(', ')}