var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        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 extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Component } from '@angular/core';
import { ComponentHelper } from '../../../classes/component-helper';
import { AuthService } from '../../../services/auth.service';
import { ToastService } from '../../../utils/toast.service';
var ForgotPasswordEcComponent = /** @class */ (function (_super) {
    __extends(ForgotPasswordEcComponent, _super);
    function ForgotPasswordEcComponent(authService, toastr) {
        var _this = _super.call(this) || this;
        _this.authService = authService;
        _this.toastr = toastr;
        _this.email = "";
        _this.loading = false;
        _this.ready = false;
        _this.recoverPassword = function (event) {
            event.preventDefault();
            if (!_this.validEmail())
                _this.toastr.show('invalid-email');
            else {
                _this.loading = true;
                _this.authService.recoverPassword(_this.email).toPromise()
                    .then(_this.processOk, _this.processOk).catch(_this.processOk);
            }
        };
        _this.processOk = function (response) {
            _this.loading = false;
            _this.ready = true;
        };
        _this.processError = function (response) {
            _this.loading = false;
            (!response || response.error)
                ? _this.toastr.show('non-existent-email')
                : _this.toastr.show(response.error);
        };
        _this.validEmail = function () { return _this.email != '' && _this.email.includes('@'); };
        _this.ecOnConstruct();
        return _this;
    }
    ForgotPasswordEcComponent.prototype.ngOnInit = function () {
        this.ecOnInit();
    };
    ForgotPasswordEcComponent.ctorParameters = function () { return [
        { type: AuthService },
        { type: ToastService }
    ]; };
    ForgotPasswordEcComponent = __decorate([
        Component({
            selector: 'app-forgot-password-ec',
            template: "<div class=\"main-container\">\n     <div *ngIf=\"!ready; else readyView\">\n          <form (submit)=\"recoverPassword($event)\">\n               <div class=\"col-12 col-md-12\">\n                    <h3>{{ 'set-forgot-email' | translate }}</h3>\n               </div>\n               <div class=\"element-container\">\n                    <input type=\"email\" [(ngModel)]=\"email\" class=\"form-control\"\n                         [ngModelOptions]=\"{standalone: true}\" />\n               </div>\n               <div class=\"element-container\">\n                    <button class=\"btn bg-golden color-white radius-0\" type=\"submit\">{{ 'recover-password' | translate }}</button>\n               </div>\n               <div *ngIf=\"loading\">\n                    <app-loading-inline-ec></app-loading-inline-ec>\n               </div>\n          </form>\n     </div>\n</div>\n\n<ng-template #readyView>\n     <div class=\"col-12 col-md-6\">\n          <div class=\"element-container\">\n               <h3>{{ 'mail-sent' | translate }}</h3>\n          </div>\n          <div class=\"element-container\">\n               <h5 class=\"center-text\">{{ 'check-your-email' | translate }}</h5>\n          </div>\n     </div>\n</ng-template>",
            styles: [".main-container{height:60vh;display:flex;flex-direction:row;justify-content:center;align-items:center}.element-container{width:100%;display:flex;justify-content:center;margin-top:5%}.center-text{text-align:center}"]
        })
    ], ForgotPasswordEcComponent);
    return ForgotPasswordEcComponent;
}(ComponentHelper));
export { ForgotPasswordEcComponent };
//# sourceMappingURL=data:application/json;base64, 