import PropTypes from 'prop-types'; import React, { Component } from 'react'; import Icon from 'Components/Icon'; import Label from 'Components/Label'; import Link from 'Components/Link/Link'; import TmdbRating from 'Components/TmdbRating'; import Tooltip from 'Components/Tooltip/Tooltip'; import { icons, kinds, sizes, tooltipPositions } from 'Helpers/Props'; import MovieDetailsLinks from 'Movie/Details/MovieDetailsLinks'; import MovieStatusLabel from 'Movie/Details/MovieStatusLabel'; import MovieIndexProgressBar from 'Movie/Index/ProgressBar/MovieIndexProgressBar'; import MoviePoster from 'Movie/MoviePoster'; import formatRuntime from 'Utilities/Date/formatRuntime'; import translate from 'Utilities/String/translate'; import AddNewMovieModal from './AddNewMovieModal'; import styles from './AddNewMovieSearchResult.css'; class AddNewMovieSearchResult extends Component { // // Lifecycle constructor(props, context) { super(props, context); this.state = { isNewAddMovieModalOpen: false }; } componentDidUpdate(prevProps) { if (!prevProps.isExistingMovie && this.props.isExistingMovie) { this.onAddMovieModalClose(); } } // // Listeners onPress = () => { this.setState({ isNewAddMovieModalOpen: true }); }; onAddMovieModalClose = () => { this.setState({ isNewAddMovieModalOpen: false }); }; onExternalLinkPress = (event) => { event.stopPropagation(); }; // // Render render() { const { tmdbId, imdbId, youTubeTrailerId, title, titleSlug, year, studio, status, overview, ratings, folder, images, isExistingMovie, isExclusionMovie, isSmallScreen, colorImpairedMode, id, monitored, hasFile, isAvailable, queueStatus, queueState, runtime, movieRuntimeFormat, certification } = this.props; const { isNewAddMovieModalOpen } = this.state; const linkProps = isExistingMovie ? { to: `/movie/${titleSlug}` } : { onPress: this.onPress }; const posterWidth = 167; const posterHeight = 250; const elementStyle = { width: `${posterWidth}px`, height: `${posterHeight}px` }; return (