refire-react
Version:
React components and helpers for Refire
73 lines • 3.31 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 __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var react_1 = require("react");
var react_redux_1 = require("react-redux");
var refire_1 = require("refire");
var resetPassword = refire_1.firebaseActions.resetPassword, clearResetPasswordError = refire_1.firebaseActions.clearResetPasswordError;
var defaultValidator = function (input) {
return !!input;
};
function default_1(options) {
if (options === void 0) { options = {}; }
var _a = options.validator, validator = _a === void 0 ? defaultValidator : _a;
return function (WrappedComponent) {
var FirebaseResetPassword = /** @class */ (function (_super) {
__extends(FirebaseResetPassword, _super);
function FirebaseResetPassword(props) {
var _this = _super.call(this, props) || this;
_this.submit = function (event) {
event.preventDefault();
_this.props.dispatch(resetPassword(_this.state.email));
};
_this.updateEmail = function (event) {
var error = _this.props._status.errors.resetPassword;
if (error) {
_this.props.dispatch(clearResetPasswordError());
}
_this.setState({ email: event.currentTarget.value });
};
_this.state = {
email: null
};
return _this;
}
FirebaseResetPassword.prototype.render = function () {
var validInput = validator(this.state.email);
var _a = this.props._status, error = _a.errors.resetPassword, processing = _a.processing.resetPassword, completed = _a.completed.resetPassword;
var extraProps = {
email: this.state.email,
submit: this.submit,
updateEmail: this.updateEmail,
validInput: validInput,
error: error,
processing: processing,
completed: completed
};
return (React.createElement(WrappedComponent, __assign({}, this.props, extraProps)));
};
return FirebaseResetPassword;
}(react_1.Component));
return react_redux_1.connect(refire_1.firebaseToProps(["_status"]))(FirebaseResetPassword);
};
}
exports.default = default_1;
//# sourceMappingURL=FirebaseResetPassword.js.map