import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { icons, kinds, sizes } from 'Helpers/Props'; import HeartRating from 'Components/HeartRating'; import Icon from 'Components/Icon'; import Label from 'Components/Label'; import Link from 'Components/Link/Link'; import ArtistPoster from 'Artist/ArtistPoster'; 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.onAddSerisModalClose(); } } // // Listeners onPress = () => { this.setState({ isNewAddSeriesModalOpen: true }); } onAddSerisModalClose = () => { this.setState({ isNewAddSeriesModalOpen: false }); } // // Render render() { const { foreignArtistId, artistName, nameSlug, year, network, status, overview, seasonCount, ratings, images, isExistingSeries, isSmallScreen } = this.props; const linkProps = isExistingSeries ? { to: `/series/${nameSlug}` } : { onPress: this.onPress }; let seasons = '1 Season'; if (seasonCount > 1) { seasons = `${seasonCount} Seasons`; } return ( { !isSmallScreen && }
{artistName} { !name.contains(year) && !!year && ({year}) } { isExistingSeries && }
{ !!network && } { !!seasonCount && } { status === 'ended' && }
{overview}
); } } AddNewSeriesSearchResult.propTypes = { foreignArtistId: PropTypes.string.isRequired, artistName: PropTypes.string.isRequired, nameSlug: PropTypes.string.isRequired, year: PropTypes.number, network: PropTypes.string, status: PropTypes.string.isRequired, overview: PropTypes.string, seasonCount: PropTypes.number, ratings: PropTypes.object.isRequired, images: PropTypes.arrayOf(PropTypes.object).isRequired, isExistingSeries: PropTypes.bool.isRequired, isSmallScreen: PropTypes.bool.isRequired }; export default AddNewSeriesSearchResult;