import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { icons } from 'Helpers/Props'; import IconButton from 'Components/Link/IconButton'; import CheckInput from 'Components/Form/CheckInput'; import Label from 'Components/Label'; import Link from 'Components/Link/Link'; import MoviePoster from 'Movie/MoviePoster'; import AddNewDiscoverMovieModal from 'DiscoverMovie/AddNewDiscoverMovieModal'; import ExcludeMovieModal from 'DiscoverMovie/Exclusion/ExcludeMovieModal'; import styles from './AddListMoviePoster.css'; class AddListMoviePoster extends Component { // // Lifecycle constructor(props, context) { super(props, context); this.state = { hasPosterError: false, isNewAddMovieModalOpen: false, isExcludeMovieModalOpen: false }; } // // Listeners onPress = () => { this.setState({ isNewAddMovieModalOpen: true }); } onAddMovieModalClose = () => { this.setState({ isNewAddMovieModalOpen: false }); } onExcludeMoviePress = () => { this.setState({ isExcludeMovieModalOpen: true }); } onExcludeMovieModalClose = () => { this.setState({ isExcludeMovieModalOpen: false }); } onPosterLoad = () => { if (this.state.hasPosterError) { this.setState({ hasPosterError: false }); } } onPosterLoadError = () => { if (!this.state.hasPosterError) { this.setState({ hasPosterError: true }); } } onChange = ({ value, shiftKey }) => { const { tmdbId, onSelectedChange } = this.props; onSelectedChange({ id: tmdbId, value, shiftKey }); } // // Render render() { const { tmdbId, title, year, overview, folder, titleSlug, images, posterWidth, posterHeight, showTitle, isExisting, isExcluded, isSelected } = this.props; const { hasPosterError, isNewAddMovieModalOpen, isExcludeMovieModalOpen } = this.state; const linkProps = isExisting ? { to: `/movie/${titleSlug}` } : { onPress: this.onPress }; const elementStyle = { width: `${posterWidth}px`, height: `${posterHeight}px` }; return (