/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { Component, Input } 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\">{{title}}</p>\n      <p class=\"is-ff-light\">{{subtitle}}</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 }
];
SignInComponent.propDecorators = {
    title: [{ type: Input }],
    subtitle: [{ type: Input }]
};
if (false) {
    /** @type {?} */
    SignInComponent.prototype.form;
    /** @type {?} */
    SignInComponent.prototype.loginError$;
    /** @type {?} */
    SignInComponent.prototype.title;
    /** @type {?} */
    SignInComponent.prototype.subtitle;
    /**
     * @type {?}
     * @private
     */
    SignInComponent.prototype.fb;
    /**
     * @type {?}
     * @private
     */
    SignInComponent.prototype.store;
    /**
     * @type {?}
     * @private
     */
    SignInComponent.prototype.auth;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjo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