import React, { Component } from "react"; import { Container, Header, Form, Grid, Segment, Input, Button, Message, Icon } from "semantic-ui-react"; import { Link } from "react-router-dom"; const returnStyle = { marginTop: "30px" }; class SendResetPassword extends Component { constructor(props) { super(props); this.handleSendResetPassword = this.handleSendResetPassword.bind(this); this.handleInputChange = this.handleInputChange.bind(this); } state = { checkInputMessages: "", email: "", emailError: false, sentReset: false }; handleInputChange = (e, { name, value }) => this.setState({ [name]: value }); handleSendResetPassword(event) { if (this.state.email === "") { this.setState({ emailError: true, checkInputMessages: "Email is required"}); } else { this.setState({ emailError: false }); this.props.sendResetPassword({email: this.state.email}).then(resetMessage => { if (resetMessage) { // report to the user is there was a problem during login this.setState({resetSent: false, checkInputMessages: resetMessage, emailError: true}); } else { this.setState({resetSent: true}); } }); } } render() { var resetMessage = ""; if (this.state.checkInputMessages.length) { resetMessage = ( Problems... {this.state.checkInputMessages} ); } return ( { !this.state.resetSent ? ( Forgot your password? Enter the email address for your account. {resetMessage} ) :( Reset Link Sent An email with a link to reset your password was sent to: {this.state.email} Back to OpenMHz )} ); } } export default SendResetPassword;