import React from 'react'; import LocalMallIcon from '@material-ui/icons/LocalMall'; import { toast } from 'react-toastify'; import Item from './marketplace/Item'; import MarketplaceFunctions from '../../modules/marketplaceFunctions'; import StoreIcon from '@material-ui/icons/Store'; import SettingsIcon from '@material-ui/icons/Settings'; export default class Addons extends React.PureComponent { constructor(...args) { super(...args); this.state = { installed: [], item_data: { name: 'Name', author: 'Author', description: 'Description', updated: '???', version: '1.0.0', icon: '' } } } async toggle(type, type2, data) { if (type === 'item') { let installed = JSON.parse(localStorage.getItem('installed')); let info = installed.find(i => i.name === data).content; this.setState({ current_data: { type: type2, name: data, content: info }, item_data: { name: info.data.name, author: info.data.author, description: MarketplaceFunctions.urlParser(info.data.description.replace(/\n/g, '
')), updated: info.updated, version: info.data.version, icon: info.data.screenshot_url } }); document.getElementById('marketplace').style.display = 'none'; document.getElementById('item').style.display = 'block'; } else { document.getElementById('marketplace').style.display = 'block'; document.getElementById('item').style.display = 'none'; } } uninstall() { MarketplaceFunctions.uninstall(this.state.current_data.name, this.state.current_data.type); toast(this.props.toastLanguage.removed); this.setState({ button: }); } componentDidMount() { document.getElementById('backgroundImage').classList.toggle('backgroundEffects'); document.getElementById('center').classList.toggle('backgroundEffects'); this.setState({ installed: JSON.parse(localStorage.getItem('installed')) }); } componentWillUnmount() { document.getElementById('backgroundImage').classList.toggle('backgroundEffects'); document.getElementById('center').classList.toggle('backgroundEffects'); } render() { if (this.state.installed.length === 0) { return
×

{this.props.modalLanguage.title}

{ /* */}

{this.props.language.added}

{this.props.language.empty.title}

{this.props.language.empty.description}

} return
×

{this.props.modalLanguage.title}

{ /* */}

{this.props.language.added}

{this.state.installed.map((item) =>
this.toggle('item', item.type, item.name)}> icon

{item.content.data.name}

{item.content.data.author}

)}
this.uninstall()}>{this.props.language.product.buttons.remove}} data={this.state.item_data} function={()=> this.toggle()} language={this.props.language.product} />
; } }