import variables from 'modules/variables';
import { PureComponent } from 'react';
import Header from '../Header';
import Radio from '../Radio';
import Checkbox from '../Checkbox';
import { TextField } from '@mui/material';
export default class TimeSettings extends PureComponent {
constructor() {
super();
this.state = {
location: localStorage.getItem('location') || '',
windSpeed: (localStorage.getItem('windspeed') !== 'true')
};
}
componentDidUpdate() {
localStorage.setItem('location', this.state.location);
}
showReminder() {
document.querySelector('.reminder-info').style.display = 'block';
localStorage.setItem('showReminder', true);
}
changeLocation(e) {
this.setState({
location: e.target.value
});
this.showReminder();
}
getAuto() {
navigator.geolocation.getCurrentPosition(async (position) => {
const data = await (await fetch(`${variables.constants.PROXY_URL}/weather/autolocation?lat=${position.coords.latitude}&lon=${position.coords.longitude}`)).json();
this.setState({
location: data[0].name
});
this.showReminder();
}, (error) => {
// firefox requires this 2nd function
console.log(error);
}, {
enableHighAccuracy: true
});
}
render() {
const getMessage = (text) => variables.language.getMessage(variables.languagecode, text);
const tempFormat = [
{
name: getMessage('modals.main.settings.sections.weather.temp_format.celsius') + ' (°C)',
value: 'celsius'
},
{
name: getMessage('modals.main.settings.sections.weather.temp_format.fahrenheit') + ' (°F)',
value: 'fahrenheit'
},
{
name: getMessage('modals.main.settings.sections.weather.temp_format.kelvin') + ' (K)',
value: 'kelvin'
}
];
return (
<>
this.changeLocation(e)} placeholder='London' varient='outlined' InputLabelProps={{ shrink: true }} />
this.getAuto()}>{getMessage('modals.main.settings.sections.weather.auto')}
{getMessage('modals.main.settings.sections.weather.extra_info.title')}
this.setState({ windSpeed: (localStorage.getItem('windspeed') !== 'true') })}/>
>
);
}
}