/* eslint-disable import/no-absolute-path */
/* eslint-disable react/jsx-indent-props */
/* eslint-disable react/jsx-indent */
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { withTracker } from 'meteor/react-meteor-data';
import { translate } from 'react-i18next';
import { Meteor } from 'meteor/meteor';
import { Map, Circle } from 'react-leaflet';
import moment from 'moment-timezone';
import Blaze from 'meteor/gadicc:blaze-react-component';
import DefMapLayers from '/imports/ui/components/Maps/DefMapLayers';
import FiresCollection from '/imports/api/Fires/Fires';
import '/imports/startup/client/comments';
import './Fires.scss';
class Fire extends React.Component {
constructor(props) {
super(props);
this.state = {
};
// console.log(moment.tz.guess());
}
render() {
const { loading, fire, t } = this.props;
if (fire && fire.when) {
this.when = moment.tz(fire.when, moment.tz.guess());
}
return (
{!loading &&
{fire.address ?
t('Información adicional sobre fuego detectado en {{where}} el {{when}}', { where: fire.address, when: this.when.format('LLLL (z)') }) :
t('Información adicional sobre fuego detectado el {{when}}', { when: this.when.format('LLLL (z)') })}
{t('Coordenadas:')} {fire.lat}, {fire.lon}
{(fire.type === 'modis' || fire.type === 'viirs') &&
{t('Fuego detectado por satélites de la NASA {{when}}', { when: this.when.fromNow() })}
}
{(fire.type === 'vecinal') &&
{t('Fuego notificado por uno de nuestros usuarios/as {{when}}', { when: this.when.fromNow() })}
}
{/* TODO: marcar tipo de fuego, industria, etc */}
{t('Comentarios')}
{t('Puedes añadir un comentario si tienes información adicional sobre este fuego.')}
{' '}
{t('Por ejemplo:')}
- {t('si conoces esta zona y cómo acceder a el fuego (esto puede de ser de ayuda para apagarlo si sigue activo o para investigarlo en un futuro)')}
- {t('si conoces el motivo por el que comenzó el fuego')}
- {t('si quieres denunciar algún tipo de ilegalidad, incluso anónimamente')}
- {t('o cualquier otra información')}
}
);
}
}
Fire.propTypes = {
t: PropTypes.func.isRequired,
loading: PropTypes.bool.isRequired,
fire: PropTypes.object // .isRequired
};
Fire.defaultProps = {
};
// export default translate([], { wait: true })(withTracker((props) => {
const FireContainer = withTracker(({ match }) => {
const fireEncrypt = match.params.id;
const subscription = Meteor.subscribe('fireFromHash', fireEncrypt);
// console.log(`Subs ready: ${subscription.ready()}, fire: ${JSON.stringify(FiresCollection.findOne())}`);
return {
loading: !subscription.ready(),
fire: FiresCollection.findOne()
};
})(Fire);
// export default FireContainer;
export default translate([], { wait: true })(FireContainer);