/**
 * @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';
export class SignInComponent {
    /**
     * @param {?} fb
     * @param {?} store
     * @param {?} auth
     */
    constructor(fb, store, auth) {
        this.fb = fb;
        this.store = store;
        this.auth = auth;
    }
    /**
     * @return {?}
     */
    ngOnInit() {
        this.form = this.fb.group({
            user: ['', Validators.required],
            password: ['', Validators.required]
        });
        this.loginError$ = this.auth.state$.pipe(pluck('error'));
    }
    /**
     * @return {?}
     */
    submitForm() {
        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 = () => [
    { type: FormBuilder },
    { type: Store },
    { type: AuthService }
];
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2lnbi1pbi5jb21wb25lbnQuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AYmlkaS9jb21tb24tY29tcG9uZW50cy8iLCJzb3VyY2VzIjpb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