import variables from 'modules/variables'; import { PureComponent, Fragment } from 'react'; import Tooltip from '../../../helpers/tooltip/Tooltip'; import { toast } from 'react-toastify'; import { MdArrowBack, MdIosShare, MdFlag, MdWarning, MdAccountCircle, MdBugReport, MdFormatQuote, MdImage, MdTranslate, MdKeyboardArrowDown, MdKeyboardArrowUp, } from 'react-icons/md'; import Modal from 'react-modal'; import { install, uninstall } from 'modules/helpers/marketplace'; import ShareModal from '../../../helpers/sharemodal/ShareModal'; export default class Item extends PureComponent { constructor(props) { super(props); this.state = { showLightbox: false, showUpdateButton: this.props.addonInstalled === true && this.props.addonInstalledVersion !== this.props.data.version, showMore: false, shareModal: false, }; } updateAddon() { uninstall(this.props.data.type, this.props.data.display_name); install(this.props.data.type, this.props.data); toast(variables.language.getMessage(variables.languagecode, 'toasts.updated')); this.setState({ showUpdateButton: false, }); } toggleShowMore() { if (this.state.showMore === true) { this.setState({ showMore: false }); } else { this.setState({ showMore: true }); } } render() { const getMessage = (text) => variables.language.getMessage(variables.languagecode, text); if (!this.props.data.display_name) { return null; } let warningHTML; if (this.props.data.quote_api) { warningHTML = (
{getMessage('modals.main.marketplace.product.quote_warning.title')}
{getMessage('modals.main.marketplace.product.quote_warning.description')}
); } // 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 = ( ); } return (
this.setState({ shareModal: false })} > this.setState({ shareModal: false })} />
Marketplace
{this.props.data.display_name} {this.props.data.author}
product this.setState({ showLightbox: true })} /> Description {this.props.data.description.length > 100 ? (
this.toggleShowMore()}> {this.state.showMore === true ? ( <> Show Less ) : ( <> Show More )}
) : null}
{getMessage('modals.main.marketplace.product.version')} {updateButton ? ( {this.props.data.version} (Installed: {this.props.data.addonInstalledVersion}) ) : ( {this.props.data.version} )}
{getMessage('modals.main.marketplace.product.author')} {this.props.data.author}
{this.props.data.data.quotes ? (
No. Quotes {this.props.data.data.quotes.length}
) : null} {this.props.data.data.photos ? (
No. Images {this.props.data.data.photos.length}
) : null} {!this.props.data.data.photos ? (
Language {this.props.data.data.language}
) : null}
Shares 324
icon {this.props.button}
this.setState({ shareModal: true })} /> window.open( variables.constants.REPORT_ITEM + this.props.data.display_name.split(' ').join('+'), '_blank', ) } />
{this.props.data.data.collection ? (
Part of Red Dead Collection
) : null} {warningHTML} {/*
Update
React > Vue
*/}
); } }