@nitor/aws-react-components
Version:
A library with React component for AWS
65 lines • 3.12 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var ResetPasswordForm_1 = require("./ResetPasswordForm");
var ErrorMessage = function (props) {
return React.createElement("p", { className: "errorMessage" },
"Error: ",
props.message);
};
var DefaultResetPasswordForm = /** @class */ (function (_super) {
__extends(DefaultResetPasswordForm, _super);
function DefaultResetPasswordForm(props) {
var _this = _super.call(this, props) || this;
_this.state = {
password1: "",
password2: "",
error: null
};
_this.handlePassword1 = _this.handlePassword1.bind(_this);
_this.handlePassword2 = _this.handlePassword2.bind(_this);
_this.handleSubmit = _this.handleSubmit.bind(_this);
return _this;
}
DefaultResetPasswordForm.prototype.handlePassword1 = function (e) {
this.setState({ password1: e.target.value });
};
DefaultResetPasswordForm.prototype.handlePassword2 = function (e) {
this.setState({ password2: e.target.value });
};
DefaultResetPasswordForm.prototype.handleSubmit = function (e) {
e.preventDefault();
if (this.state.password1 != this.state.password2) {
this.setState({ error: "Passwords do not match" });
return;
}
if (this.state.password1.length < 1) {
this.setState({ error: "Password must not be empty" });
return;
}
this.props.returnNewPassword(this.state.password1);
};
DefaultResetPasswordForm.prototype.render = function () {
return (React.createElement("div", null,
this.props.error && React.createElement(ErrorMessage, { message: this.props.error }),
this.state.error && React.createElement(ErrorMessage, { message: this.state.error }),
React.createElement("h4", null, "Please enter a new password"),
React.createElement("form", { onSubmit: this.handleSubmit },
React.createElement("input", { type: "password", name: "password1", onChange: this.handlePassword1, placeholder: "New password" }),
React.createElement("input", { type: "password", name: "password2", onChange: this.handlePassword2, placeholder: "Confirm new password" }),
React.createElement("input", { type: "submit" }))));
};
return DefaultResetPasswordForm;
}(ResetPasswordForm_1.ResetPasswordForm));
exports.DefaultResetPasswordForm = DefaultResetPasswordForm;
//# sourceMappingURL=DefaultResetPasswordForm.js.map