import variables from 'modules/variables'; import { PureComponent } from 'react'; import { Radio as RadioUI, RadioGroup, FormControlLabel, FormControl, FormLabel, } from '@mui/material'; import EventBus from 'modules/helpers/eventbus'; import translations from 'modules/translations'; export default class Radio extends PureComponent { constructor(props) { super(props); this.state = { value: localStorage.getItem(this.props.name), }; } handleChange = async (e) => { const { value } = e.target; if (value === 'loading') { return; } if (this.props.name === 'language') { // old tab name if (localStorage.getItem('tabName') === variables.getMessage('tabname')) { localStorage.setItem('tabName', translations[value.replace('-', '_')].tabname); } } localStorage.setItem(this.props.name, value); this.setState({ value, }); if (this.props.onChange) { this.props.onChange(value); } variables.stats.postEvent('setting', `${this.props.name} from ${this.state.value} to ${value}`); if (this.props.element) { if (!document.querySelector(this.props.element)) { document.querySelector('.reminder-info').style.display = 'flex'; return localStorage.setItem('showReminder', true); } } EventBus.dispatch('refresh', this.props.category); }; render() { return ( {this.props.title} {this.props.options.map((option) => ( } label={option.name} key={option.name} /> ))} ); } }