import React from 'react'; import { Row, Alert, FormGroup, ControlLabel, Button } from 'react-bootstrap'; import Col from '../../components/Col/Col'; import PropTypes from 'prop-types'; import { Link } from 'react-router-dom'; import { Accounts } from 'meteor/accounts-base'; import { Bert } from 'meteor/themeteorchef:bert'; import { Helmet } from 'react-helmet'; import AccountPageFooter from '../../components/AccountPageFooter/AccountPageFooter'; import validate from '../../../modules/validate'; import { translate } from 'react-i18next'; import { T9n } from 'meteor-accounts-t9n'; class RecoverPassword extends React.Component { constructor(props) { super(props); this.t = props.t; this.handleSubmit = this.handleSubmit.bind(this); } componentDidMount() { const component = this; validate(component.form, { rules: { emailAddress: { required: true, email: true } }, messages: { emailAddress: { required: this.t('Necesitamos un correo aquí.'), email: this.t('¿Es este correo correcto?') } }, submitHandler() { component.handleSubmit(); } }); } handleSubmit() { const { history } = this.props; const email = this.emailAddress.value; const t = this.props.t; Accounts.forgotPassword({ email, t }, (error) => { if (error) { Bert.alert(T9n.get(`error.accounts.${error.reason}`), 'danger'); } else { Bert.alert(t('checkResetEmail', { email }), 'success'); history.push('/login'); } }); } render() { return (
{this.t('AppName')}: {this.t('Recupera tu contraseña')}

{this.t('Recupera tu contraseña')}

{this.t('Introduce tu correo abajo para recibir un enlace para resetear tu contraseña.')}
(this.form = form)} onSubmit={event => event.preventDefault()}> {this.t('Correo electrónico')} (this.emailAddress = emailAddress)} className="form-control" />

{this.t('¿Recuerdas tu contraseña?')} {this.t('Iniciar sesión')}.

); } } RecoverPassword.propTypes = { history: PropTypes.object.isRequired }; export default translate([], { wait: true })(RecoverPassword);