import variables from 'modules/variables';
import { PureComponent } from 'react';
import {
MdSettings,
MdOutlineShoppingBasket,
MdOutlineExtension,
MdRefresh,
MdClose,
} from 'react-icons/md';
import Tab from './Tab';
import ErrorBoundary from '../../../ErrorBoundary';
export default class Tabs extends PureComponent {
constructor(props) {
super(props);
this.state = {
currentTab: this.props.children[0].props.label,
currentName: this.props.children[0].props.name,
};
}
onClick = (tab, name) => {
if (name !== this.state.currentName) {
variables.stats.postEvent('tab', `Opened ${name}`);
}
this.setState({
currentTab: tab,
currentName: name,
});
};
render() {
const display = localStorage.getItem('showReminder') === 'true' ? 'flex' : 'none';
const reminderInfo = (
{variables.getMessage('modals.main.settings.reminder.title')}
localStorage.setItem('showReminder', false)}>
{variables.getMessage('modals.main.settings.reminder.message')}
);
let settingsActive = '';
let addonsActive = '';
let marketplaceActive = '';
switch (this.props.current) {
case 'settings':
settingsActive = ' navbar-item-active';
break;
case 'addons':
addonsActive = ' navbar-item-active';
break;
case 'marketplace':
marketplaceActive = ' navbar-item-active';
break;
default:
break;
}
return (
{this.props.children.map((tab, index) => (
this.onClick(nextTab, tab.props.name)}
navbarTab={this.props.navbar || false}
/>
))}
{reminderInfo}
{this.props.children.map((tab) => {
if (tab.props.label !== this.state.currentTab) {
return undefined;
}
return tab.props.children;
})}
);
}
}