import variables from 'config/variables'; import { PureComponent, Fragment } from 'react'; import { toast } from 'react-toastify'; import { MdIosShare, MdFlag, MdAccountCircle, MdBugReport, MdFormatQuote, MdImage, MdTranslate, MdExpandMore, MdExpandLess, MdStyle, } from 'react-icons/md'; import Modal from 'react-modal'; import { Header } from 'components/Layout/Settings'; import { Button } from 'components/Elements'; import { install, uninstall } from 'utils/marketplace'; import { Carousel } from '../Elements/Carousel'; import { ShareModal } from 'components/Elements'; import { MdClose } from 'react-icons/md'; class Item extends PureComponent { constructor(props) { super(props); this.state = { showLightbox: false, showUpdateButton: this.props.addonInstalled === true && this.props.addonInstalledVersion !== this.props.data.version, shareModal: false, count: 5, }; } updateAddon() { uninstall(this.props.data.type, this.props.data.display_name); install(this.props.data.type, this.props.data); toast(variables.getMessage('toasts.updated')); this.setState({ showUpdateButton: false, }); } incrementCount(type) { const newCount = this.state.count !== this.props.data.data[type].length ? this.props.data.data[type].length : 5; this.setState({ count: newCount }); } getName(name) { const nameMappings = { photos: 'photo_packs', quotes: 'quote_packs', settings: 'preset_settings', }; return nameMappings[name] || name; } render() { if (!this.props.data.display_name) { return null; } // prevent console error let iconsrc = variables.constants.DDG_IMAGE_PROXY + this.props.data.icon; if (!this.props.data.icon) { iconsrc = null; } let updateButton; if (this.state.showUpdateButton) { updateButton = ( )} ); } } export { Item as default, Item };