import { Component } from '@angular/core';
import { Validators } from '@angular/forms';
import { AppValidators } from '../../../validations/AppValidators';
import { BasePage } from '../../BasePage';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "../../../services/claimant/claimant.service";
import * as i3 from "../../../services/util/util.service";
import * as i4 from "@ionic/angular";
import * as i5 from "@angular/common";
import * as i6 from "primeng/api";
import * as i7 from "@angular/material/form-field";
import * as i8 from "primeng/tabview";
import * as i9 from "@angular/material/input";
import * as i10 from "primeng/table";
import * as i11 from "../../../components/ssn/ssn.component";
function UserSearchComponent_mat_hint_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "mat-hint");
    i0.ɵɵtext(1, " At least one search criteria is required. ");
    i0.ɵɵelementEnd();
} }
function UserSearchComponent_mat_error_23_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "mat-error");
    i0.ɵɵtext(1, " User ID should have minimum ");
    i0.ɵɵelementStart(2, "strong");
    i0.ɵɵtext(3, "5 characters");
    i0.ɵɵelementEnd()();
} }
function UserSearchComponent_mat_error_29_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "mat-error");
    i0.ɵɵtext(1, " SSN should have ");
    i0.ɵɵelementStart(2, "strong");
    i0.ɵɵtext(3, "9 digits");
    i0.ɵɵelementEnd()();
} }
function UserSearchComponent_div_42_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 3);
    i0.ɵɵelement(1, "ion-spinner", 17);
    i0.ɵɵelementEnd();
} }
function UserSearchComponent_div_43_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div")(1, "ion-label", 18);
    i0.ɵɵtext(2, "No record(s) present to display.");
    i0.ɵɵelementEnd()();
} }
function UserSearchComponent_div_44_ng_template_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "tr")(1, "th", 23);
    i0.ɵɵtext(2, "First Name ");
    i0.ɵɵelement(3, "p-sortIcon", 24);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "th", 25);
    i0.ɵɵtext(5, "Last Name ");
    i0.ɵɵelement(6, "p-sortIcon", 26);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(7, "th");
    i0.ɵɵtext(8, "SSN");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(9, "th", 27);
    i0.ɵɵtext(10, "User ID ");
    i0.ɵɵelement(11, "p-sortIcon", 28);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(12, "th");
    i0.ɵɵtext(13, "Action");
    i0.ɵɵelementEnd()();
} }
function UserSearchComponent_div_44_ng_template_4_Template(rf, ctx) { if (rf & 1) {
    const _r11 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "tr", 29)(1, "td");
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "td");
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "td", 3);
    i0.ɵɵelement(6, "app-ssn", 30);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(7, "td");
    i0.ɵɵtext(8);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(9, "td", 3)(10, "ion-button", 31);
    i0.ɵɵlistener("click", function UserSearchComponent_div_44_ng_template_4_Template_ion_button_click_10_listener() { const restoredCtx = i0.ɵɵrestoreView(_r11); const claimant_r9 = restoredCtx.$implicit; const ctx_r10 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r10.openClaimant(claimant_r9)); });
    i0.ɵɵelement(11, "ion-icon", 32);
    i0.ɵɵtext(12, " View ");
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const claimant_r9 = ctx.$implicit;
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(claimant_r9.firstName);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(claimant_r9.lastName);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ssn", claimant_r9.ssn);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(claimant_r9.userId);
} }
const _c0 = () => [5, 15, 30];
function UserSearchComponent_div_44_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div")(1, "p-table", 19, 20);
    i0.ɵɵtemplate(3, UserSearchComponent_div_44_ng_template_3_Template, 14, 0, "ng-template", 21)(4, UserSearchComponent_div_44_ng_template_4_Template, 13, 4, "ng-template", 22);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r5 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("value", ctx_r5.results)("rowHover", true)("rows", 5)("showCurrentPageReport", true)("rowsPerPageOptions", i0.ɵɵpureFunction0(7, _c0))("paginator", true)("filterDelay", 0);
} }
export class UserSearchComponent extends BasePage {
    constructor(fb, cs, util, nav, popup) {
        super();
        this.fb = fb;
        this.cs = cs;
        this.util = util;
        this.nav = nav;
        this.popup = popup;
        this.index = 0;
        this.results = [];
    }
    ngOnInit() {
        this.initializeSearchForm();
    }
    initializeSearchForm() {
        this.searchForm = this.fb.group({
            'firstName': [],
            'lastName': [],
            'userId': [],
            'ssn': []
        }, {
            validators: AppValidators.selectAtleastOne(Validators.required)
        });
    }
    get firstName() {
        return this.searchForm.get('firstName');
    }
    get lastName() {
        return this.searchForm.get('lastName');
    }
    get userId() {
        return this.searchForm.get('userId');
    }
    get ssn() {
        return this.searchForm.get('ssn');
    }
    search() {
        if (this.searchForm.invalid) {
            return;
        }
        this.showLoader();
        let searchCriteria = this.searchForm.value;
        this.index = 3;
        this.cs
            .search(searchCriteria)
            .subscribe(res => {
            this.hideLoader();
            this.results = res;
        }, err => {
            this.hideLoader();
            this.results = [];
        });
    }
    reset() {
        this.searchForm.reset();
        this.results = [];
    }
    openClaimant(value) {
        this.cs.getClaimant().next(value);
        this.popup.dismiss(null);
        setTimeout(() => {
            this.nav.navigateForward('/reset-password');
        }, 250);
    }
    handleTabChange(event) {
        this.index = event.index;
    }
    static { this.ɵfac = function UserSearchComponent_Factory(t) { return new (t || UserSearchComponent)(i0.ɵɵdirectiveInject(i1.UntypedFormBuilder), i0.ɵɵdirectiveInject(i2.ClaimantService), i0.ɵɵdirectiveInject(i3.UtilService), i0.ɵɵdirectiveInject(i4.NavController), i0.ɵɵdirectiveInject(i4.PopoverController)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: UserSearchComponent, selectors: [["app-user-search"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 45, vars: 11, consts: [[1, "app-box"], [3, "activeIndex", "onChange"], ["header", "Claimant Search"], [1, "ion-text-center"], [4, "ngIf"], ["appearance", "outline"], ["matInput", "", "maxlength", "30", 3, "formControl"], ["matInput", "", "minlength", "5", "maxlength", "30", 3, "formControl"], ["matInput", "", "minlength", "9", "maxlength", "9", 3, "formControl"], ["shape", "round", "color", "success", 3, "click"], ["name", "search-outline", "slot", "start"], ["shape", "round", "color", "medium", 3, "click"], ["name", "refresh-sharp", "slot", "start"], ["header", "Employer Search"], ["header", "Internal User Search"], ["header", "Result(s)"], ["class", "ion-text-center", 4, "ngIf"], ["name", "dots"], ["color", "danger"], ["dataKey", "claimantId", "styleClass", "app-table", "currentPageReportTemplate", "Showing {first} to {last} of {totalRecords} entries", "showLoader", "true", 1, "ion-padding", 3, "value", "rowHover", "rows", "showCurrentPageReport", "rowsPerPageOptions", "paginator", "filterDelay"], ["dt", ""], ["pTemplate", "header"], ["pTemplate", "body"], ["pSortableColumn", "firstName"], ["field", "firstName"], ["pSortableColumn", "lastName"], ["field", "lastName"], ["pSortableColumn", "userId"], ["field", "userId"], [1, "ui-selectable-row"], [3, "ssn"], ["size", "small", "shape", "round", "color", "success", 3, "click"], ["slot", "start", "name", "eye"]], template: function UserSearchComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "ion-content")(1, "div", 0)(2, "p-tabView", 1);
            i0.ɵɵlistener("onChange", function UserSearchComponent_Template_p_tabView_onChange_2_listener($event) { return ctx.handleTabChange($event); });
            i0.ɵɵelementStart(3, "p-tabPanel", 2)(4, "div", 3);
            i0.ɵɵtemplate(5, UserSearchComponent_mat_hint_5_Template, 2, 0, "mat-hint", 4);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(6, "ion-row")(7, "ion-col", 3)(8, "mat-form-field", 5)(9, "mat-label");
            i0.ɵɵtext(10, "First Name");
            i0.ɵɵelementEnd();
            i0.ɵɵelement(11, "input", 6);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(12, "ion-col", 3)(13, "mat-form-field", 5)(14, "mat-label");
            i0.ɵɵtext(15, "Last Name");
            i0.ɵɵelementEnd();
            i0.ɵɵelement(16, "input", 6);
            i0.ɵɵelementEnd()()();
            i0.ɵɵelementStart(17, "ion-row")(18, "ion-col", 3)(19, "mat-form-field", 5)(20, "mat-label");
            i0.ɵɵtext(21, "User ID");
            i0.ɵɵelementEnd();
            i0.ɵɵelement(22, "input", 7);
            i0.ɵɵtemplate(23, UserSearchComponent_mat_error_23_Template, 4, 0, "mat-error", 4);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(24, "ion-col", 3)(25, "mat-form-field", 5)(26, "mat-label");
            i0.ɵɵtext(27, "SSN");
            i0.ɵɵelementEnd();
            i0.ɵɵelement(28, "input", 8);
            i0.ɵɵtemplate(29, UserSearchComponent_mat_error_29_Template, 4, 0, "mat-error", 4);
            i0.ɵɵelementEnd()()();
            i0.ɵɵelementStart(30, "div", 3)(31, "ion-button", 9);
            i0.ɵɵlistener("click", function UserSearchComponent_Template_ion_button_click_31_listener() { return ctx.search(); });
            i0.ɵɵelement(32, "ion-icon", 10);
            i0.ɵɵtext(33, " Search ");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(34, "ion-button", 11);
            i0.ɵɵlistener("click", function UserSearchComponent_Template_ion_button_click_34_listener() { return ctx.reset(); });
            i0.ɵɵelement(35, "ion-icon", 12);
            i0.ɵɵtext(36, " Reset ");
            i0.ɵɵelementEnd()()();
            i0.ɵɵelementStart(37, "p-tabPanel", 13);
            i0.ɵɵtext(38, " Coming Soon... ");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(39, "p-tabPanel", 14);
            i0.ɵɵtext(40, " Coming Soon... ");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(41, "p-tabPanel", 15);
            i0.ɵɵtemplate(42, UserSearchComponent_div_42_Template, 2, 0, "div", 16)(43, UserSearchComponent_div_43_Template, 3, 0, "div", 4)(44, UserSearchComponent_div_44_Template, 5, 8, "div", 4);
            i0.ɵɵelementEnd()()()();
        } if (rf & 2) {
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("activeIndex", ctx.index);
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngIf", ctx.searchForm.hasError("selectAtleastOne"));
            i0.ɵɵadvance(6);
            i0.ɵɵproperty("formControl", ctx.firstName);
            i0.ɵɵadvance(5);
            i0.ɵɵproperty("formControl", ctx.lastName);
            i0.ɵɵadvance(6);
            i0.ɵɵproperty("formControl", ctx.userId);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.userId.hasError("minlength"));
            i0.ɵɵadvance(5);
            i0.ɵɵproperty("formControl", ctx.ssn);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.ssn.hasError("minlength"));
            i0.ɵɵadvance(13);
            i0.ɵɵproperty("ngIf", ctx.loading);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.loading && ctx.results.length < 1);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.loading && ctx.results.length > 0);
        } }, dependencies: [i4.IonButton, i4.IonCol, i4.IonContent, i4.IonIcon, i4.IonLabel, i4.IonRow, i4.IonSpinner, i5.NgIf, i6.PrimeTemplate, i7.MatFormField, i7.MatLabel, i7.MatHint, i7.MatError, i8.TabView, i8.TabPanel, i1.DefaultValueAccessor, i1.NgControlStatus, i1.MinLengthValidator, i1.MaxLengthValidator, i1.FormControlDirective, i9.MatInput, i10.Table, i10.SortableColumn, i10.SortIcon, i11.SsnComponent] }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UserSearchComponent, [{
        type: Component,
        args: [{ selector: 'app-user-search', template: "<ion-content>\r\n    <div class=\"app-box\">\r\n        <p-tabView [activeIndex]=\"index\" (onChange)=\"handleTabChange($event)\">\r\n            <p-tabPanel header=\"Claimant Search\">\r\n                <div class=\"ion-text-center\">\r\n                    <mat-hint *ngIf=\"searchForm.hasError('selectAtleastOne')\">\r\n                        At least one search criteria is required.\r\n                    </mat-hint>\r\n                </div>\r\n                <ion-row>\r\n                    <ion-col class=\"ion-text-center\">\r\n                        <mat-form-field appearance=\"outline\">\r\n                            <mat-label>First Name</mat-label>\r\n                            <input matInput [formControl]=\"firstName\" maxlength=\"30\">\r\n                        </mat-form-field>\r\n                    </ion-col>\r\n\r\n                    <ion-col class=\"ion-text-center\">\r\n                        <mat-form-field appearance=\"outline\">\r\n                            <mat-label>Last Name</mat-label>\r\n                            <input matInput [formControl]=\"lastName\" maxlength=\"30\">\r\n                        </mat-form-field>\r\n                    </ion-col>\r\n\r\n                </ion-row>\r\n                <ion-row>\r\n                    <ion-col class=\"ion-text-center\">\r\n                        <mat-form-field appearance=\"outline\">\r\n                            <mat-label>User ID</mat-label>\r\n                            <input matInput [formControl]=\"userId\" minlength=\"5\" maxlength=\"30\">\r\n                            <mat-error *ngIf=\"userId.hasError('minlength')\">\r\n                                User ID should have minimum <strong>5 characters</strong>\r\n                            </mat-error>\r\n                        </mat-form-field>\r\n                    </ion-col>\r\n                    <ion-col class=\"ion-text-center\">\r\n                        <mat-form-field appearance=\"outline\">\r\n                            <mat-label>SSN</mat-label>\r\n                            <input matInput [formControl]=\"ssn\" minlength=\"9\" maxlength=\"9\">\r\n                            <mat-error *ngIf=\"ssn.hasError('minlength')\">\r\n                                SSN should have <strong>9 digits</strong>\r\n                            </mat-error>\r\n                        </mat-form-field>\r\n                    </ion-col>\r\n                </ion-row>\r\n                <div class=\"ion-text-center\">\r\n                    <ion-button shape=\"round\" (click)=\"search()\" color=\"success\">\r\n                        <ion-icon name=\"search-outline\" slot=\"start\"></ion-icon>\r\n                        Search\r\n                    </ion-button>\r\n                    <ion-button shape=\"round\" (click)=\"reset()\" color=\"medium\">\r\n                        <ion-icon name=\"refresh-sharp\" slot=\"start\"></ion-icon>\r\n                        Reset\r\n                    </ion-button>\r\n                </div>\r\n            </p-tabPanel>\r\n\r\n            <p-tabPanel header=\"Employer Search\">\r\n                Coming Soon...\r\n            </p-tabPanel>\r\n\r\n            <p-tabPanel header=\"Internal User Search\">\r\n                Coming Soon...\r\n            </p-tabPanel>\r\n\r\n            <p-tabPanel header=\"Result(s)\">\r\n                <div *ngIf=\"loading\" class=\"ion-text-center\">\r\n                    <ion-spinner name=\"dots\"></ion-spinner>\r\n                </div>\r\n                <div *ngIf=\"!loading && results.length < 1\">\r\n                    <ion-label color=\"danger\">No record(s) present to display.</ion-label>\r\n                </div>\r\n                <div *ngIf=\"!loading && results.length > 0\">\r\n                    <p-table #dt [value]=\"results\" dataKey=\"claimantId\" styleClass=\"app-table\" [rowHover]=\"true\"\r\n                        [rows]=\"5\" [showCurrentPageReport]=\"true\" [rowsPerPageOptions]=\"[5,15,30]\"\r\n                        [paginator]=\"true\" currentPageReportTemplate=\"Showing &#123;first&#125; to &#123;last&#125; of &#123;totalRecords&#125; entries\"\r\n                        [filterDelay]=\"0\" showLoader=\"true\" class=\"ion-padding\">\r\n                        \r\n                        <ng-template pTemplate=\"header\">\r\n                            <tr>\r\n                                <th pSortableColumn=\"firstName\">First Name <p-sortIcon field=\"firstName\"></p-sortIcon></th>\r\n                                <th pSortableColumn=\"lastName\">Last Name <p-sortIcon field=\"lastName\"></p-sortIcon></th>\r\n                                <th >SSN</th>\r\n                                <th pSortableColumn=\"userId\">User ID <p-sortIcon field=\"userId\"></p-sortIcon></th>\r\n                                <th >Action</th>\r\n                            </tr>\r\n                        </ng-template>\r\n                        <ng-template pTemplate=\"body\" let-claimant>\r\n                            <tr class=\"ui-selectable-row\">\r\n                                <td>{{claimant.firstName}}</td>\r\n                                <td>{{claimant.lastName}}</td>\r\n                                <td class=\"ion-text-center\">\r\n                                    <app-ssn [ssn]=\"claimant.ssn\"></app-ssn>\r\n                                </td>\r\n                                <td>{{claimant.userId}}</td>\r\n                                <td class=\"ion-text-center\">\r\n                                    <ion-button size=\"small\" shape=\"round\"  color=\"success\" (click)=openClaimant(claimant)>\r\n                                    <ion-icon slot=\"start\" name=\"eye\"></ion-icon>\r\n                                    View\r\n                                    </ion-button>\r\n                                </td>\r\n                            </tr>\r\n                        </ng-template>\r\n                    </p-table>\r\n                </div>\r\n            </p-tabPanel>\r\n        </p-tabView>\r\n    </div>\r\n</ion-content>" }]
    }], () => [{ type: i1.UntypedFormBuilder }, { type: i2.ClaimantService }, { type: i3.UtilService }, { type: i4.NavController }, { type: i4.PopoverController }], null); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(UserSearchComponent, { className: "UserSearchComponent", filePath: "lib\\pages\\popovers\\user-search\\user-search.component.ts", lineNumber: 15 }); })();
//# sourceMappingURL=data:application/json;base64, 