import PropTypes from 'prop-types'; import React from 'react'; import getRelativeDate from 'Utilities/Date/getRelativeDate'; import formatBytes from 'Utilities/Number/formatBytes'; import styles from './ArtistIndexBannerInfo.css'; function ArtistIndexBannerInfo(props) { const { qualityProfile, showQualityProfile, previousAiring, added, albumCount, path, sizeOnDisk, sortKey, showRelativeDates, shortDateFormat, timeFormat } = props; if (sortKey === 'qualityProfileId' && !showQualityProfile) { return (
{qualityProfile.name}
); } if (sortKey === 'previousAiring' && previousAiring) { return (
{ getRelativeDate( previousAiring, shortDateFormat, showRelativeDates, { timeFormat, timeForToday: true } ) }
); } if (sortKey === 'added' && added) { const addedDate = getRelativeDate( added, shortDateFormat, showRelativeDates, { timeFormat, timeForToday: false } ); return (
{`Added ${addedDate}`}
); } if (sortKey === 'albumCount') { let albums = '1 album'; if (albumCount === 0) { albums = 'No albums'; } else if (albumCount > 1) { albums = `${albumCount} albums`; } return (
{albums}
); } if (sortKey === 'path') { return (
{path}
); } if (sortKey === 'sizeOnDisk') { return (
{formatBytes(sizeOnDisk)}
); } return null; } ArtistIndexBannerInfo.propTypes = { qualityProfile: PropTypes.object.isRequired, showQualityProfile: PropTypes.bool.isRequired, previousAiring: PropTypes.string, added: PropTypes.string, albumCount: PropTypes.number.isRequired, path: PropTypes.string.isRequired, sizeOnDisk: PropTypes.number, sortKey: PropTypes.string.isRequired, showRelativeDates: PropTypes.bool.isRequired, shortDateFormat: PropTypes.string.isRequired, timeFormat: PropTypes.string.isRequired }; export default ArtistIndexBannerInfo;