import PropTypes from 'prop-types'; import React, { Component } from 'react'; import AuthorPoster from 'Author/AuthorPoster'; import DeleteAuthorModal from 'Author/Delete/DeleteAuthorModal'; import EditAuthorModalConnector from 'Author/Edit/EditAuthorModalConnector'; import AuthorIndexProgressBar from 'Author/Index/ProgressBar/AuthorIndexProgressBar'; import CheckInput from 'Components/Form/CheckInput'; import Label from 'Components/Label'; import IconButton from 'Components/Link/IconButton'; import Link from 'Components/Link/Link'; import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; import { icons } from 'Helpers/Props'; import getRelativeDate from 'Utilities/Date/getRelativeDate'; import translate from 'Utilities/String/translate'; import AuthorIndexPosterInfo from './AuthorIndexPosterInfo'; import styles from './AuthorIndexPoster.css'; class AuthorIndexPoster extends Component { // // Lifecycle constructor(props, context) { super(props, context); this.state = { hasPosterError: false, isEditAuthorModalOpen: false, isDeleteAuthorModalOpen: false }; } // // Listeners onEditAuthorPress = () => { this.setState({ isEditAuthorModalOpen: true }); }; onEditAuthorModalClose = () => { this.setState({ isEditAuthorModalOpen: false }); }; onDeleteAuthorPress = () => { this.setState({ isEditAuthorModalOpen: false, isDeleteAuthorModalOpen: true }); }; onDeleteAuthorModalClose = () => { this.setState({ isDeleteAuthorModalOpen: false }); }; onPosterLoad = () => { if (this.state.hasPosterError) { this.setState({ hasPosterError: false }); } }; onPosterLoadError = () => { if (!this.state.hasPosterError) { this.setState({ hasPosterError: true }); } }; onChange = ({ value, shiftKey }) => { const { id, onSelectedChange } = this.props; onSelectedChange({ id, value, shiftKey }); }; // // Render render() { const { id, authorName, authorNameLastFirst, monitored, titleSlug, status, nextAiring, statistics = {}, images, posterWidth, posterHeight, detailedProgressBar, showTitle, showMonitored, showQualityProfile, qualityProfile, metadataProfile, showSearchAction, showRelativeDates, shortDateFormat, timeFormat, isRefreshingAuthor, isSearchingAuthor, onRefreshAuthorPress, onSearchPress, isEditorActive, isSelected, onSelectedChange, ...otherProps } = this.props; const { bookCount = 0, availableBookCount = 0, bookFileCount = 0, totalBookCount = 0, sizeOnDisk = 0 } = statistics; const { hasPosterError, isEditAuthorModalOpen, isDeleteAuthorModalOpen } = this.state; const link = `/author/${titleSlug}`; const elementStyle = { width: `${posterWidth}px`, height: `${posterHeight}px`, objectFit: 'contain' }; return (
{ isEditorActive &&
} { status === 'ended' &&
} { hasPosterError &&
{authorName}
}
{ showTitle !== 'no' &&
{showTitle === 'firstLast' ? authorName : authorNameLastFirst}
} { showMonitored &&
{monitored ? 'Monitored' : 'Unmonitored'}
} {showQualityProfile && !!qualityProfile?.name ? (
{qualityProfile.name}
) : null} { nextAiring &&
{ getRelativeDate( nextAiring, shortDateFormat, showRelativeDates, { timeFormat, timeForToday: true } ) }
}
); } } AuthorIndexPoster.propTypes = { id: PropTypes.number.isRequired, authorName: PropTypes.string.isRequired, authorNameLastFirst: PropTypes.string.isRequired, monitored: PropTypes.bool.isRequired, status: PropTypes.string.isRequired, titleSlug: PropTypes.string.isRequired, nextAiring: PropTypes.string, statistics: PropTypes.object.isRequired, images: PropTypes.arrayOf(PropTypes.object).isRequired, posterWidth: PropTypes.number.isRequired, posterHeight: PropTypes.number.isRequired, detailedProgressBar: PropTypes.bool.isRequired, showTitle: PropTypes.string.isRequired, showMonitored: PropTypes.bool.isRequired, showQualityProfile: PropTypes.bool.isRequired, qualityProfile: PropTypes.object.isRequired, metadataProfile: PropTypes.object.isRequired, showSearchAction: PropTypes.bool.isRequired, showRelativeDates: PropTypes.bool.isRequired, shortDateFormat: PropTypes.string.isRequired, timeFormat: PropTypes.string.isRequired, isRefreshingAuthor: PropTypes.bool.isRequired, isSearchingAuthor: PropTypes.bool.isRequired, onRefreshAuthorPress: PropTypes.func.isRequired, onSearchPress: PropTypes.func.isRequired, isEditorActive: PropTypes.bool.isRequired, isSelected: PropTypes.bool, onSelectedChange: PropTypes.func.isRequired }; AuthorIndexPoster.defaultProps = { statistics: { bookCount: 0, bookFileCount: 0, totalBookCount: 0 } }; export default AuthorIndexPoster;