UNPKG

@nitor/aws-react-components

Version:
64 lines 2.63 kB
"use strict"; 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 LoginForm_1 = require("./LoginForm"); var ErrorMessage = function (_a) { var error = _a.error; if (!error) { return null; } return (React.createElement("p", null, error)); }; var DefaultLoginForm = /** @class */ (function (_super) { __extends(DefaultLoginForm, _super); function DefaultLoginForm(props) { var _this = _super.call(this, props) || this; _this.state = { username: "", password: "" }; _this.handleUsername = _this .handleUsername .bind(_this); _this.handlePassword = _this .handlePassword .bind(_this); _this.handleSubmit = _this .handleSubmit .bind(_this); return _this; } DefaultLoginForm.prototype.handleUsername = function (e) { this.setState({ username: e.target.value }); }; DefaultLoginForm.prototype.handlePassword = function (e) { this.setState({ password: e.target.value }); }; DefaultLoginForm.prototype.handleSubmit = function (e) { e.preventDefault(); this .props .loginHandler(this.state.username, this.state.password); }; DefaultLoginForm.prototype.render = function () { return (React.createElement("div", null, React.createElement(ErrorMessage, { error: this.props.error }), React.createElement("form", { onSubmit: this.handleSubmit }, React.createElement("input", { type: "text", value: this.state.username, name: "username", placeholder: "Username", onChange: this.handleUsername }), React.createElement("input", { type: "password", value: this.state.password, name: "password", placeholder: "Password", onChange: this.handlePassword }), React.createElement("input", { type: "submit" })))); }; return DefaultLoginForm; }(LoginForm_1.LoginForm)); exports.DefaultLoginForm = DefaultLoginForm; //# sourceMappingURL=DefaultLoginForm.js.map