/**
 * @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';
var SignUpComponent = /** @class */ (function () {
    function SignUpComponent(fb, store) {
        this.fb = fb;
        this.store = store;
        this.submitted = false;
        this.passValid = false;
        this.endPoint = '';
        this.role = '';
    }
    /**
     * @return {?}
     */
    SignUpComponent.prototype.ngOnInit = /**
     * @return {?}
     */
    function () {
        this.errorPass = '';
        this.form = this.fb.group({
            first_name: [null, Validators.required],
            last_name: ['', Validators.required],
            dni: ['', Validators.required],
            password: ['', Validators.required],
            pass_con: ['', Validators.required],
            role: [this.role, Validators.required],
        });
    };
    /**
     * @param {?} event
     * @param {?} form
     * @return {?}
     */
    SignUpComponent.prototype.onSubmit = /**
     * @param {?} event
     * @param {?} form
     * @return {?}
     */
    function (event, form) {
        event.preventDefault();
        this.submitted = true;
        if (form.invalid) {
            return;
        }
        this.passValid = this.validPass(form.value.password, form.value.pass_con);
        if (!this.passValid) {
            this.errorPass = 'Las contraseñas deben ser iguales';
            return;
        }
        this.data = {
            'user': JSON.stringify(form.value),
            'url': this.endPoint
        };
        //this.store.dispatch();
    };
    /**
     * @param {?} pass
     * @param {?} pass_con
     * @return {?}
     */
    SignUpComponent.prototype.validPass = /**
     * @param {?} pass
     * @param {?} pass_con
     * @return {?}
     */
    function (pass, pass_con) {
        (pass !== pass_con) ? this.flag = false : this.flag = true;
        return this.flag;
    };
    SignUpComponent.decorators = [
        { type: Component, args: [{
                    selector: 'bidi-sign-up',
                    template: "<form [formGroup]=\"form\" (ngSubmit)=\"onSubmit($event, form)\">\n  <div class=\"field\">\n    <input class=\"form-control\" formControlName=\"first_name\" type=\"text\" placeholder=\"NOMBRE\">\n    <label class=\"label\">Ingresa tu nombre</label>\n    <div\n      *ngIf=\"form.controls['first_name'].invalid && (form.controls['first_name'].dirty || form.controls['first_name'].touched)\"\n      class=\"alert alert-danger\"\n    >\n      <div *ngIf=\"form.controls['first_name'].errors.required\">\n        Nombre es obligatorio.\n      </div>\n    </div>\n  </div>\n  <div class=\"field\">\n    <input class=\"form-control\" formControlName=\"last_name\" type=\"text\" placeholder=\"APELLIDO\">\n    <label class=\"label\">Ingresa tu apellido</label>\n    <div\n      *ngIf=\"form.controls['last_name'].invalid && (form.controls['last_name'].dirty || form.controls['last_name'].touched)\"\n      class=\"alert alert-danger\"\n    >\n      <div *ngIf=\"form.controls['last_name'].errors.required\">Apellido es obligatorio.</div>\n    </div>\n  </div>\n  <div class=\"field\">\n    <input class=\"form-control\" formControlName=\"dni\" type=\"text\" placeholder=\"DNI\">\n    <label class=\"label\">Ingresa tu DNI</label>\n    <div\n      *ngIf=\"form.controls['dni'].invalid && (form.controls['dni'].dirty || form.controls['dni'].touched)\"\n      class=\"alert alert-danger\"\n    >\n      <div *ngIf=\"form.controls['dni'].errors.required\">DNI es obligatorio.</div>\n    </div>\n  </div>\n  <div class=\"field\">\n    <input class=\"form-control\" formControlName=\"password\" type=\"password\" placeholder=\"CONTRASE\u00D1A\">\n    <label class=\"label\">Ingresa tu contrase\u00F1a</label>\n    <div\n      *ngIf=\"form.controls['password'].invalid && (form.controls['password'].dirty || form.controls['password'].touched)\"\n      class=\"alert alert-danger\"\n    >\n      <div *ngIf=\"form.controls['password'].errors.required\">Contrase\u00F1a es obligatorio.</div>\n    </div>\n  </div>\n  <div class=\"field\">\n    <input class=\"form-control\" formControlName=\"pass_con\" type=\"password\" placeholder=\"CONTRASE\u00D1A\">\n    <label class=\"label\">Repite tu contrase\u00F1a</label>\n    <div\n      *ngIf=\"form.controls['pass_con'].invalid && (form.controls['pass_con'].dirty || form.controls['pass_con'].touched)\"\n      class=\"alert alert-danger\">\n      <div *ngIf=\"form.controls['pass_con'].errors.required\">Contrase\u00F1a es Obligatorio.</div>\n    </div>\n    <span>{{ errorPass }}</span>\n  </div>\n  <div class=\"control has-text-centered\">\n    <button type=\"submit\" [disabled]=\"form.pristine || form.invalid\" class=\"btn btn-success\">Registrar</button>\n  </div>\n</form>\n",
                    styles: [""]
                }] }
    ];
    /** @nocollapse */
    SignUpComponent.ctorParameters = function () { return [
        { type: FormBuilder },
        { type: Store }
    ]; };
    SignUpComponent.propDecorators = {
        endPoint: [{ type: Input }],
        role: [{ type: Input }]
    };
    return SignUpComponent;
}());
export { SignUpComponent };
if (false) {
    /** @type {?} */
    SignUpComponent.prototype.flag;
    /** @type {?} */
    SignUpComponent.prototype.submitted;
    /** @type {?} */
    SignUpComponent.prototype.passValid;
    /** @type {?} */
    SignUpComponent.prototype.errorPass;
    /** @type {?} */
    SignUpComponent.prototype.data;
    /** @type {?} */
    SignUpComponent.prototype.form;
    /** @type {?} */
    SignUpComponent.prototype.endPoint;
    /** @type {?} */
    SignUpComponent.prototype.role;
    /**
     * @type {?}
     * @private
     */
    SignUpComponent.prototype.fb;
    /**
     * @type {?}
     * @private
     */
    SignUpComponent.prototype.store;
}
//# sourceMappingURL=data:application/json;base64, 