1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-20 21:54:58 -04:00
Files
Sonarr/frontend/src/Series/Index/Posters/SeriesIndexPosterInfo.tsx
T
2024-08-11 08:46:56 -07:00

160 lines
3.6 KiB
TypeScript

import React from 'react';
import TagListConnector from 'Components/TagListConnector';
import Language from 'Language/Language';
import QualityProfile from 'typings/QualityProfile';
import formatDateTime from 'Utilities/Date/formatDateTime';
import getRelativeDate from 'Utilities/Date/getRelativeDate';
import formatBytes from 'Utilities/Number/formatBytes';
import translate from 'Utilities/String/translate';
import styles from './SeriesIndexPosterInfo.css';
interface SeriesIndexPosterInfoProps {
originalLanguage?: Language;
network?: string;
showQualityProfile: boolean;
qualityProfile?: QualityProfile;
previousAiring?: string;
added?: string;
seasonCount: number;
path: string;
sizeOnDisk?: number;
tags: number[];
sortKey: string;
showRelativeDates: boolean;
shortDateFormat: string;
longDateFormat: string;
timeFormat: string;
showTags: boolean;
}
function SeriesIndexPosterInfo(props: SeriesIndexPosterInfoProps) {
const {
originalLanguage,
network,
qualityProfile,
showQualityProfile,
previousAiring,
added,
seasonCount,
path,
sizeOnDisk = 0,
tags,
sortKey,
showRelativeDates,
shortDateFormat,
longDateFormat,
timeFormat,
showTags,
} = props;
if (sortKey === 'network' && network) {
return (
<div className={styles.info} title={translate('Network')}>
{network}
</div>
);
}
if (sortKey === 'originalLanguage' && !!originalLanguage?.name) {
return (
<div className={styles.info} title={translate('OriginalLanguage')}>
{originalLanguage.name}
</div>
);
}
if (
sortKey === 'qualityProfileId' &&
!showQualityProfile &&
!!qualityProfile?.name
) {
return (
<div className={styles.info} title={translate('QualityProfile')}>
{qualityProfile.name}
</div>
);
}
if (sortKey === 'previousAiring' && previousAiring) {
return (
<div
className={styles.info}
title={`${translate('PreviousAiring')}: ${formatDateTime(
previousAiring,
longDateFormat,
timeFormat
)}`}
>
{getRelativeDate({
date: previousAiring,
shortDateFormat,
showRelativeDates,
timeFormat,
timeForToday: true,
})}
</div>
);
}
if (sortKey === 'added' && added) {
const addedDate = getRelativeDate({
date: added,
shortDateFormat,
showRelativeDates,
timeFormat,
timeForToday: false,
});
return (
<div
className={styles.info}
title={formatDateTime(added, longDateFormat, timeFormat)}
>
{translate('Added')}: {addedDate}
</div>
);
}
if (sortKey === 'seasonCount') {
let seasons = translate('OneSeason');
if (seasonCount === 0) {
seasons = translate('NoSeasons');
} else if (seasonCount > 1) {
seasons = translate('CountSeasons', { count: seasonCount });
}
return <div className={styles.info}>{seasons}</div>;
}
if (!showTags && sortKey === 'tags' && tags.length) {
return (
<div className={styles.tags}>
<div className={styles.tagsList}>
<TagListConnector tags={tags} />
</div>
</div>
);
}
if (sortKey === 'path') {
return (
<div className={styles.info} title={translate('Path')}>
{path}
</div>
);
}
if (sortKey === 'sizeOnDisk') {
return (
<div className={styles.info} title={translate('SizeOnDisk')}>
{formatBytes(sizeOnDisk)}
</div>
);
}
return null;
}
export default SeriesIndexPosterInfo;