import React, { Component } from "react"; import { Button, Form, Grid, Header, Image, Icon, Message, } from "semantic-ui-react"; import { Redirect } from "react-router-dom"; import { Forms } from "../remote"; export default class ChangePass extends Component { constructor(props) { super(props); this.state = { password: "", error: { state: false, message: "", }, success: false, }; this.handleChangePassword = this.handleChangePassword.bind(this); } onChangeHandler = (event) => { let nam = event.target.name; let val = event.target.value; this.setState({ [nam]: val }); }; handleChangePassword = (e) => { if (this.state.confirmPassword !== this.state.password) { this.setState({ error: { state: true, message: "Passwords do not match.", }, }); } Forms.submitResetPassword(this.props.query.token, this.state.password) .then(() => this.setState({ success: true })) .catch((err) => this.setState({ error: { state: true, message: err.messages.join(" - ") }, }) ); }; render() { if (this.state.success) { return ; } return (
Reset Password
); } }