/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { Component } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms';
import { Store } from '@ngrx/store';
import { AuthService } from '../auth.service';
import { Login } from '../ngrx/actions';
import { pluck } from 'rxjs/operators';
var SignInComponent = /** @class */ (function () {
    function SignInComponent(fb, store, auth) {
        this.fb = fb;
        this.store = store;
        this.auth = auth;
    }
    /**
     * @return {?}
     */
    SignInComponent.prototype.ngOnInit = /**
     * @return {?}
     */
    function () {
        this.form = this.fb.group({
            user: ['', Validators.required],
            password: ['', Validators.required]
        });
        this.loginError$ = this.auth.state$.pipe(pluck('error'));
    };
    /**
     * @return {?}
     */
    SignInComponent.prototype.submitForm = /**
     * @return {?}
     */
    function () {
        if (this.form.invalid) {
            return;
        }
        this.store.dispatch(new Login({
            user: this.form.value.user.toLowerCase(),
            password: this.form.value.password
        }));
    };
    SignInComponent.decorators = [
        { type: Component, args: [{
                    selector: 'bidi-sign-in',
                    template: "<div class=\"sing-in \">\n  <div class=\"miscleanea\"></div>\n  <div class=\"miscleanea\" style=\"    left: 0;\n  width: 39%;\n  bottom: -147px;\"></div>\n  <div class=\"columns is-uppercase\">\n    <div class=\"column is-narrow is-offset-1\">\n      <p class=\"is-ff-black\">Bienvenido a ticmas</p>\n      <p class=\"is-ff-light\">Herramientas del docente</p>\n    </div>\n  </div>\n  <div class=\"columns\">\n\n    <div class=\"column is-7 is-offset-5\">\n      <div class=\"form-container fade-in\">\n        <form [formGroup]=\"form\" (ngSubmit)=\"submitForm()\">\n          <div class=\"field\">\n            <div class=\"control\">\n              <input\n                class=\"form-control\"\n                formControlName=\"user\"\n                type=\"text\"\n                placeholder=\"escribe tu usuario\">\n            </div>\n            <div\n              *ngIf=\"form.controls['user'].invalid && (form.controls['user'].dirty || form.controls['user'].touched)\"\n            >\n              <div *ngIf=\"form.controls['user'].errors.required\" class=\"error-alert has-text-centered is-size-7\">\n                El nombre de usuario es obligatorio.\n              </div>\n            </div>\n          </div>\n          <div class=\"field\">\n            <div class=\"control\">\n              <input\n                class=\"form-control\"\n                type=\"password\"\n                formControlName=\"password\"\n                placeholder=\"escribe tu contrase\u00F1a\">\n            </div>\n            <div\n              *ngIf=\"form.controls['password'].invalid && (form.controls['password'].dirty || form.controls['password'].touched)\"\n            >\n              <div *ngIf=\"form.controls['password'].errors.required\" class=\"error-alert has-text-centered is-size-7\">\n                La contrase\u00F1a es obligatoria.\n              </div>\n            </div>\n          </div>\n          <div class=\"control has-text-centered\">\n\n            <div class=\"buttons\">\n              <button type=\"submit\" [disabled]=\"form.invalid\" class=\"button is-circle-medium is-white\">\n                <svg style=\"fill: #00F699;\" width=\"24\" height=\"24\" xmlns=\"http://www.w3.org/2000/svg\"\n                     fill-rule=\"evenodd\" clip-rule=\"evenodd\">\n                  <path d=\"M21 6.285l-11.16 12.733-6.84-6.018 1.319-1.49 5.341 4.686 9.865-11.196 1.475 1.285z\"/>\n                </svg>\n              </button>\n            </div>\n\n          </div>\n        </form>\n        <span\n          *ngIf=\"loginError$ | async\"\n          class=\"error has-background-danger has-text-light is-size-6 is-uppercase has-text-centered\"\n        >\n          Ha ocurrido un error, intenta nuevamente\n        </span>\n      </div>\n\n    </div>\n  </div>\n</div>\n",
                    styles: [""]
                }] }
    ];
    /** @nocollapse */
    SignInComponent.ctorParameters = function () { return [
        { type: FormBuilder },
        { type: Store },
        { type: AuthService }
    ]; };
    return SignInComponent;
}());
export { SignInComponent };
if (false) {
    /** @type {?} */
    SignInComponent.prototype.form;
    /** @type {?} */
    SignInComponent.prototype.loginError$;
    /**
     * @type {?}
     * @private
     */
    SignInComponent.prototype.fb;
    /**
     * @type {?}
     * @private
     */
    SignInComponent.prototype.store;
    /**
     * @type {?}
     * @private
     */
    SignInComponent.prototype.auth;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2lnbi1pbi5jb21wb25lbnQuanMiLCJ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