import PropTypes from 'prop-types'; import React, { Component } from 'react'; import HeartRating from 'Components/HeartRating'; import Icon from 'Components/Icon'; import Label from 'Components/Label'; import Link from 'Components/Link/Link'; import MetadataAttribution from 'Components/MetadataAttribution'; import { icons, kinds, sizes } from 'Helpers/Props'; import SeriesPoster from 'Series/SeriesPoster'; import translate from 'Utilities/String/translate'; import AddNewSeriesModal from './AddNewSeriesModal'; import styles from './AddNewSeriesSearchResult.css'; class AddNewSeriesSearchResult extends Component { // // Lifecycle constructor(props, context) { super(props, context); this.state = { isNewAddSeriesModalOpen: false }; } componentDidUpdate(prevProps) { if (!prevProps.isExistingSeries && this.props.isExistingSeries) { this.onAddSeriesModalClose(); } } // // Listeners onPress = () => { this.setState({ isNewAddSeriesModalOpen: true }); }; onAddSeriesModalClose = () => { this.setState({ isNewAddSeriesModalOpen: false }); }; onTVDBLinkPress = (event) => { event.stopPropagation(); }; // // Render render() { const { tvdbId, title, titleSlug, year, network, status, overview, statistics, ratings, folder, seriesType, images, isExistingSeries, isSmallScreen } = this.props; const seasonCount = statistics.seasonCount; const { isNewAddSeriesModalOpen } = this.state; const linkProps = isExistingSeries ? { to: `/series/${titleSlug}` } : { onPress: this.onPress }; let seasons = translate('OneSeason'); if (seasonCount > 1) { seasons = translate('CountSeasons', { count: seasonCount }); } return (