1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-22 22:16:13 -04:00
Files
Sonarr/frontend/src/Series/Index/Posters/SeriesIndexPosterInfo.tsx
T
2024-05-22 20:07:31 -07:00

145 lines
3.2 KiB
TypeScript

import React from 'react';
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;
sortKey: string;
showRelativeDates: boolean;
shortDateFormat: string;
longDateFormat: string;
timeFormat: string;
}
function SeriesIndexPosterInfo(props: SeriesIndexPosterInfoProps) {
const {
originalLanguage,
network,
qualityProfile,
showQualityProfile,
previousAiring,
added,
seasonCount,
path,
sizeOnDisk,
sortKey,
showRelativeDates,
shortDateFormat,
longDateFormat,
timeFormat,
} = 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 (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;