import PropTypes from 'prop-types'; import React from 'react'; import getRelativeDate from 'Utilities/Date/getRelativeDate'; import formatBytes from 'Utilities/Number/formatBytes'; import styles from './MovieIndexPosterInfo.css'; function MovieIndexPosterInfo(props) { const { studio, qualityProfile, showQualityProfile, added, inCinemas, digitalRelease, physicalRelease, certification, path, sizeOnDisk, sortKey, showRelativeDates, shortDateFormat, timeFormat } = props; if (sortKey === 'studio' && studio) { return (
{studio}
); } if (sortKey === 'qualityProfileId' && !showQualityProfile) { return (
{qualityProfile.name}
); } if (sortKey === 'added' && added) { const addedDate = getRelativeDate( added, shortDateFormat, showRelativeDates, { timeFormat, timeForToday: false } ); return (
{`translate('Added') ${addedDate}`}
); } if (sortKey === 'inCinemas' && inCinemas) { const inCinemasDate = getRelativeDate( inCinemas, shortDateFormat, showRelativeDates, { timeFormat, timeForToday: false } ); return (
{`translate('InCinemas') ${inCinemasDate}`}
); } if (sortKey === 'digitalRelease' && digitalRelease) { const digitalReleaseDate = getRelativeDate( digitalRelease, shortDateFormat, showRelativeDates, { timeFormat, timeForToday: false } ); return (
{`translate('Digital') ${digitalReleaseDate}`}
); } if (sortKey === 'physicalRelease' && physicalRelease) { const physicalReleaseDate = getRelativeDate( physicalRelease, shortDateFormat, showRelativeDates, { timeFormat, timeForToday: false } ); return (
{`translate('Released') ${physicalReleaseDate}`}
); } if (sortKey === 'path') { return (
{path}
); } if (sortKey === 'sizeOnDisk') { return (
{formatBytes(sizeOnDisk)}
); } if (sortKey === 'certification') { return (
{certification}
); } return null; } MovieIndexPosterInfo.propTypes = { studio: PropTypes.string, showQualityProfile: PropTypes.bool.isRequired, qualityProfile: PropTypes.object.isRequired, added: PropTypes.string, inCinemas: PropTypes.string, certification: PropTypes.string, digitalRelease: PropTypes.string, physicalRelease: PropTypes.string, 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 MovieIndexPosterInfo;