import PropTypes from 'prop-types'; import React from 'react'; import getRelativeDate from 'Utilities/Date/getRelativeDate'; import formatBytes from 'Utilities/Number/formatBytes'; import styles from './AuthorIndexPosterInfo.css'; function AuthorIndexPosterInfo(props) { const { qualityProfile, showQualityProfile, metadataProfile, added, nextBook, lastBook, bookCount, path, sizeOnDisk, sortKey, showRelativeDates, shortDateFormat, timeFormat } = props; if (sortKey === 'qualityProfileId' && !showQualityProfile) { return (
{qualityProfile.name}
); } if (sortKey === 'metadataProfileId') { return (
{metadataProfile.name}
); } if (sortKey === 'added' && added) { const addedDate = getRelativeDate( added, shortDateFormat, showRelativeDates, { timeFormat, timeForToday: false } ); return (
{`Added ${addedDate}`}
); } if (sortKey === 'nextBook' && nextBook) { const date = getRelativeDate( nextBook.releaseDate, shortDateFormat, showRelativeDates, { timeFormat, timeForToday: false } ); return (
{`Next Book ${date}`}
); } if (sortKey === 'lastBook' && lastBook) { const date = getRelativeDate( lastBook.releaseDate, shortDateFormat, showRelativeDates, { timeFormat, timeForToday: false } ); return (
{`Last Book ${date}`}
); } if (sortKey === 'bookCount') { let books = '1 book'; if (bookCount === 0) { books = 'No books'; } else if (bookCount > 1) { books = `${bookCount} books`; } return (
{books}
); } if (sortKey === 'path') { return (
{path}
); } if (sortKey === 'sizeOnDisk') { return (
{formatBytes(sizeOnDisk)}
); } return null; } AuthorIndexPosterInfo.propTypes = { qualityProfile: PropTypes.object.isRequired, showQualityProfile: PropTypes.bool.isRequired, metadataProfile: PropTypes.object.isRequired, added: PropTypes.string, nextBook: PropTypes.object, lastBook: PropTypes.object, bookCount: 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 AuthorIndexPosterInfo;