import variables from 'config/variables';
import { PureComponent, Fragment } from 'react';
import { Tooltip } from 'components/Elements';
import ImageCarousel from 'features/helpers/carousel/Carousel';
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 { ShareModal } from 'components/Elements';
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 = (
{variables.getMessage('modals.main.settings.sections.quote.title')} | {variables.getMessage('modals.main.settings.sections.quote.author')} |
---|---|
{quote.quote} | {quote.author} |
{variables.getMessage('modals.main.marketplace.product.setting')} | {variables.getMessage('modals.main.marketplace.product.value')} |
---|---|
{key} | {value} |
{variables.getMessage('modals.main.marketplace.product.description')}