/** * @Component Name: CustomerComponent * @Module: Home * @Module Functionality : To display the customer information * @Creation Date: August 12,2017 * @Author: sbaireddy * @Version: 1.0 */ import { Component, OnInit, OnDestroy, Output, EventEmitter, ViewChild } from '@angular/core'; import { Router } from '@angular/router'; import { IDormantProperties } from '../../shared/modal/common'; import CartUtils from '../../shared/cart.utils'; import { STATES } from '../../shared/form.constants'; import * as Constants from '../../shared/constants'; import { Customer, ICreditEligibilityReq, CreditEligibilityReq, ICreditEligibilityRes } from '../../shared/modal/customer'; import { Cart } from '../../shared/modal/cart'; import { User } from '../../shared/modal/user'; import { SharedService } from '../../shared/shared.service'; import { UserService } from '../../services/user.service'; import { CustomerService } from '../../services/customer.service'; import { CartService } from '../../services/cart.service'; import Utils from '../../shared/utils'; import * as _ from 'underscore'; // To do complex array and object functions @Component({ selector: 'customer-cmp', moduleId: module.id, templateUrl: 'customer.component.html', styleUrls: ['customer.component.css'] }) export class CustomerComponent implements OnInit, OnDestroy { private COMPONENT_NAME: string = 'CustomerComponent'; clearAllStatus: boolean = false; stateItems: any[]; customerModel: any = { address1: '', address2: '', city: '', dealerCode: '', email1: '', firstName: '', lastName: '', middleName: '', phone1: '', state: null, validDealerCode: false, webOrderId: '', zipCode: '', eligibility:'',eligibilityDate:'',paymentCount:'',brandType:'',accountNumber:'',nonTMOMobileNumber:'',nonTMOMobilePin:'', isValidated:false, eligibilityMsg:'',isorderlookup: false}; disableFields: boolean = false; cartSummaryData: any = {}; @ViewChild('conflictModel') conflictModel: any; @ViewChild('manualReviewModel') manualReviewModel: any; hasItemsInCart: boolean = false; creditType: string = Constants.CREDIT_CHECK; // toggle between credit type[CC/NC] bdStoreId: number = Constants.STORE_ID_BD; rtStoreId: number = Constants.STORE_ID_RT; cdStoreId: number = Constants.STORE_ID_CD; csStoreId: number = Constants.STORE_ID_CS; creditClassS: string = Constants.CREDIT_CLASS_S; cart: Cart; subscription: any; storeId: number; // updating storeid //dealerCode : number; customer: any; user: User; KarmaTestResult: any = {}; isEmailAvailable: boolean = false; showCreditDetail: boolean = true; hasPOAddress: boolean = false; bannerName: string = Constants.BANNER_ZIPCODE; //US335007 dormantProperties: IDormantProperties; suucessmsg: string; public customerModelpin: string; test : string; successmsg : string; eligibilityReq:ICreditEligibilityReq; public isValidated:boolean; eligibilityErrorMsg:string; eligibilityMsg:string; isAALOrder: boolean = false; constructor( public sharedService: SharedService, public userService: UserService, public customerService: CustomerService, public cartService: CartService, public router: Router ) { console.log('[start]-CustomerComponent.constructor()'); } /** * This function is used to initialize the directive/component after Angular * first displays the data-bound properties.It is invoked only once when the * directive is instantiated.Here it is initializing all the states, payment methods and card types * @returns void */ ngOnInit(): void { const METHOD_NAME: string = 'ngOnInit()'; console.log('[start]-CustomerComponent.ngOnInit()'); this.sharedService.updateErrorMessage(null); // Start-Switch Channel-Store id update this.sharedService.storeId.subscribe((val: number) => { this.storeId = val; }); this.sharedService.showClearAll(false); // making sure, clear all is false this.sharedService.clearAllStatus.subscribe((val: boolean) => { this.clearAllStatus = val; }); this.stateItems = STATES.filter(stateItem => stateItem); // getting cart changes... this.cart = this.cartService.getCart(); this.subscription = this.cartService.hasUpdate.subscribe((item) => { if (item) { this.cart = this.cartService.getCart(); if (this.cart && this.cart.customer && this.cart.customer.creditProfile && this.cart.customer.creditProfile.creditClass === Constants.CREDIT_CLASS_S) { this.manualReviewModel.show(); } } this.initializeCustomer(); }); this.user = this.userService.getUser(); this.customer = this.customerService.getCustomer(); if(this.customer && this.customer.creditProfile && this.customer.creditProfile.accountNumber){ this.isAALOrder = this.customer.creditProfile.accountNumber ? true : false; } this.dormantProperties = this.sharedService.getDormantProperties(); // Picking only the keys that is belonged to the customer model. if (this.customerService.getCustomerModel()) { this.customerModel = Object.assign(this.customerModel, _.pick(this.customerService.getCustomerModel(), ...(_.keys(this.customerModel)))); } this.initializeCustomer(); if (this.customer) { this.isZipCodePromoEligible(); } console.log('[end]-CustomerComponent.ngOnInit()'); } /** * Cleanup just before Angular destroys the directive/component. * Unsubscribe Observables and detach event handlers to avoid memory leaks. * @returns void */ ngOnDestroy(): void { const METHOD_NAME: string = 'ngOnDestroy()'; console.log('Destroying the objects initilized.'); if (!this.clearAllStatus && !this.customer && !(this.cart && this.cart.customer)) { let canSaveTheCustomer: boolean = false; this.customerService.setCustomerModel(this.customerModel); if (this.customerModel.firstName && this.customerModel.lastName && this.customerModel.address1 && this.customerModel.city && this.customerModel.state && this.customerModel.zipCode && this.customerModel.phone1) { canSaveTheCustomer = true; } if (canSaveTheCustomer) { console.log('Creating a cart for save the customer data.'); if (!this.cart) { const inputData: any = CartUtils.createCartInput(this.storeId, this.user); this.sharedService.showSpinner(true); // spinner this.cartService.createCartDetails(this.storeId, inputData).subscribe(result => { this.sharedService.showSpinner(false); // spinner this.cart = result; this.saveCustomerProfile(); }, error => { this.sharedService.showSpinner(false); // spinner console.error('error=>' + error); this.sharedService.showErrorMessage(error, true); }); } else { this.saveCustomerProfile(); } } } // unsubscribing the subscription this.subscription.unsubscribe(); } /**initializing the customer component */ /** * This function is used to update customer using updateCustomerModel() * @returns void */ initializeCustomer(): void { const METHOD_NAME: string = 'initializeCustomer()'; // console.log('[start]-CustomerComponent.initializeCustomer()'); if (this.customer && this.customer.creditProfile && this.customer.creditProfile.accountNumber) { console.log('Customer account#' + this.customer.creditProfile.accountNumber); this.disableFields = true; // disabling the fields this.creditType = this.customer.creditType ? this.customer.creditType : Constants.CREDIT_CHECK; this.sharedService.updateCreditChoice(this.creditType); this.customerModel = Object.assign({}, this.customer); // formatting/copy more elements from cart this.updateCustomerModel(); if (this.customer.creditProfile.taxTreatment === Constants.MIXED_TAX_TREATMENT || this.customer.creditProfile.isDelinquent || this.customer.creditProfile.effectiveDate || (this.customer.creditProfile.accountType === Constants.ACCOUNT_TYPE_I && this.customer.creditProfile.accountSubType === Constants.ACCOUNT_SUB_TYPE_S)) { if ((this.customer.creditProfile.accountType === Constants.ACCOUNT_TYPE_I && this.customer.creditProfile.accountSubType === Constants.ACCOUNT_SUB_TYPE_S)) { this.sharedService.showErrorMessage('_ERR_SOLE_PROPRIETOR', false); } else if (this.customer.creditProfile.isDelinquent) { this.sharedService.showErrorMessage('_ERR_DELINQUENT_CUSTOMER', false); } else if (this.customer.creditProfile.taxTreatment === Constants.MIXED_TAX_TREATMENT || this.customer.creditProfile.effectiveDate) { this.sharedService.showErrorMessage('_ERR_FUTURE_DATED_TAX_TREATMENT', false); } } else if (this.cart && !this.cart.customer) { console.log('updating the app defaults'); this.sharedService.updateCreditChoice(this.creditType); this.customer.orderId = this.cart.orderId; this.assosiateCustomerToCart(this.customer); } } else if (this.cart && this.cart.customer) { // checking the customer object from cart console.log('customer details exists from cart.'); if (this.cart.customer.creditProfile) { if (this.cart.customer.creditProfile.creditClass && this.cart.customer.creditType) { const creditType: string = this.cart.customer.creditType; if (creditType === Constants.CREDIT_CHECK || creditType === Constants.NOCREDIT_CHECK) { this.disableFields = true; // disabling the fields this.customer = this.cart.customer; this.creditType = creditType; } } else if (this.cart.customer.creditProfile.accountNumber) { const creditType: string = this.cart.customer.creditProfile.isNCFPlan ? Constants.CREDIT_CHECK : Constants.NOCREDIT_CHECK; if (creditType === Constants.CREDIT_CHECK || creditType === Constants.NOCREDIT_CHECK) { this.disableFields = true; // disabling the fields this.cart.customer.creditType = creditType; this.customer = this.cart.customer; this.creditType = creditType; } } } const validDealerCode = this.customerModel.validDealerCode; // saivng the dealer code const isorderlookup = this.customerModel.isorderlookup; this.customerModel = Object.assign({}, this.cart.customer); this.customerModel.validDealerCode = validDealerCode; this.customerModel.isorderlookup = isorderlookup; // have to save phonenumber and pin // formatting/copy more elements from cart this.updateCustomerModel(); } else { // formatting/copy more elements from cart this.updateCustomerModel(); } // console.log('[end]-CustomerComponent.initializeCustomer()'); } /** *This function is used to update customer model with customer details. * @returns void */ updateCustomerModel(): void { const METHOD_NAME: string = 'updateCustomerModel()'; if (this.cart) { if (this.cart.customer && this.cart.customer.creditProfile && this.cart.customer.creditProfile.identifier && this.customer && this.customer.nonTMOMobileNumber) { this.customerModel.isorderlookup = true; } if (this.cart.dealerCode) { this.customerModel.validDealerCode = true; this.customerModel.dealerCode = this.cart.dealerCode; } else { this.customerModel.validDealerCode  = (this.customerModel.validDealerCode) ? this.customerModel.validDealerCode : false; this.customerModel.dealerCode  = (this.customerModel.dealerCode) ? this.customerModel.dealerCode : ''; } this.customerModel.webOrderId = this.cart.webOrderId ? this.cart.webOrderId : ''; this.customerModel.corpNode = this.cart.corpNode ? this.cart.corpNode : ''; this.customerModel.companyName = this.cart.companyName ? this.cart.companyName : ''; } if (!this.customerModel.validDealerCode) { if (this.storeId !== Constants.STORE_ID_BD) { this.customerModel.validDealerCode = (this.user.permissions.isSupervisor || this.user.permissions.isWTS) ? false : true; } } if(this.storeId != this.rtStoreId){ this.customerModel.phone1 = Utils.formatPhoneNumber(this.customerModel.phone1); } this.customerModel.nonTMOMobileNumber = Utils.formatPhoneNumber(this.customerModel.nonTMOMobileNumber); this.isEmailAvailable = this.customerModel.email1 ? true : false; if (this.storeId === Constants.STORE_ID_CS && !this.user.permissions.isTICUserEligibleForNewActivation) { this.showCreditDetail = false; } else if (this.storeId === Constants.STORE_ID_RT) { this.showCreditDetail = false; } } /**switch credit type */ /**switch credit type */ /** * This function is used to set the credit type * @param {string} creditType contains valid credit type. * @returns void */ switchCreditType(creditType: string): void { const METHOD_NAME: string = 'switchCreditType()'; this.sharedService.addLogging(this.COMPONENT_NAME, METHOD_NAME, 'Switching credit type'); console.log('CustomerComponent.switchCreditType()>>>' + creditType); if (this.cart && this.cart.customer && this.cart.customer.creditType) { if (this.cart.customer.creditType !== creditType) { if (this.cart.packages && this.cart.packages.length > 0) { if (this.cart.customer.altCustomerId) { this.conflictModel.show(); this.hasItemsInCart = true; } else { // this.revertBackCreditType(creditType); } } else { if (this.cart.customer.altCustomerId) { this.updateCreditType(this.cart.orderId, creditType); } } } } } /** * This function is used to revert back credit type based on credit type * @param {string} creditType contains valid credit type * @returns void */ revertBackCreditType(creditType: string): void { const METHOD_NAME: string = 'revertBackCreditType()'; // not changing the credit type if (creditType === Constants.CREDIT_CHECK) { this.creditType = Constants.NOCREDIT_CHECK; } else if (creditType === Constants.NOCREDIT_CHECK) { this.creditType = Constants.CREDIT_CHECK; } } /** * This function is used to update the customer in cart using customer and cart services. * @param {Customer} customer * @returns void */ assosiateCustomerToCart(customer: Customer): void { const METHOD_NAME: string = 'assosiateCustomerToCart()'; this.sharedService.addLogging(this.COMPONENT_NAME, METHOD_NAME, 'Assosiating the customer to cart'); console.log('assosiating the customer to cart'); if (customer.orderNotes) { this.sharedService.addOrderNotes(this.storeId, this.cart.orderId, customer.orderNotes); customer.orderNotes = null; } this.sharedService.showSpinner(true); // spinner this.customerService.createCustomer(this.storeId, customer).subscribe(result => { this.KarmaTestResult = result; this.sharedService.showSpinner(false); // spinner this.customerService.setCustomer(null); this.cart.customer = this.customer; this.cart.customer.addressId = result.addressId; this.cartService.setCart(this.cart); if (this.cart.packages && this.cart.packages.length > 0) { this.removeConflicts(Constants.ADD_LINE); } console.log('Successfully added.'); }, error => { this.sharedService.showSpinner(false); // spinner this.sharedService.showErrorMessage(error, true); console.error('error=>' + error) }); } /** * This function is used to update revert back credit type. * @param {number} orderId contains valid order number * @param {string} creditType contains valid credit type * @returns void */ updateCreditType(orderId: number, creditType: string): void { const METHOD_NAME: string = 'updateCreditType()'; this.sharedService.addLogging(this.COMPONENT_NAME, METHOD_NAME, 'Updating credit type'); const inputData: any = { 'orderId': this.cart.orderId, 'creditType': creditType }; this.sharedService.showSpinner(true); // spinner this.customerService.switchCreditType(this.storeId, inputData).subscribe(result => { this.sharedService.showSpinner(false); // spinner console.log('Successfully switched credit type.'); // updating the new credit type data this.cart.customer = result; this.cartService.setCart(this.cart); this.sharedService.updateCreditChoice(creditType); console.log('re-initializing the customer data'); this.initializeCustomer(); if (this.cart.packages && this.cart.packages.length > 0) { this.removeConflicts(Constants.NEW_PACKAGE); } }, error => { this.sharedService.showSpinner(false); // spinner this.sharedService.showErrorMessage(error, true); console.error('error=>' + error); // revert back credit type this.hasItemsInCart = false; this.revertBackCreditType(creditType); }); } /** * This function is used to get cart summary and to update cart. * @param {string} resolveType contains valid resolve type. * @returns void */ removeConflicts(resolveType: string): void { const METHOD_NAME: string = 'removeConflicts()'; const inputData: any = { 'resolveType': resolveType }; this.sharedService.showSpinner(true); // spinner this.cartService.resolveConflicts(this.storeId, this.cart.orderId, inputData).subscribe(result => { this.sharedService.showSpinner(false); // spinner console.log('Resolved conflicts successfully.'); this.sharedService.showSpinner(true); // spinner this.cartService.getCartSummary(this.storeId, this.cart.orderId).subscribe(getCartSummaryResult => { this.cartSummaryData = getCartSummaryResult; this.sharedService.showSpinner(false); // spinner this.cartService.setCart(Object.assign(this.cart, getCartSummaryResult)); }, error => { this.sharedService.showSpinner(false); // spinner this.sharedService.showErrorMessage(error, true); console.error('error=>' + error); }); }, error => { this.sharedService.showSpinner(false); // spinner console.error('error=>' + error); this.sharedService.showErrorMessage(error, true); }); } /** * This function is used to validate dealer code using user service and to update dealer code. * @param {any} element * @returns void */ validateDealerCode(element: any): void { const METHOD_NAME: string = 'validateDealerCode()'; this.sharedService.addLogging(this.COMPONENT_NAME, METHOD_NAME, 'Validating dealer code'); if (element.value && element.valid && element.value.length === 8 && Utils.checkDealerCode (element.value)) { const inputData: any = { dealerCode: element.value }; const userId = this.userService.getUser().userId; this.sharedService.showSpinner(true); // spinner this.userService.validateDealerCode(this.storeId, userId, inputData).subscribe(result => { this.sharedService.showSpinner(false); // spinner this.customerModel.validDealerCode = result.isDealerValid; if (!result.isDealerValid) { // element.value = null; this.customerModel.dealerCode = ''; this.sharedService.showErrorMessage('_ERR_DEALER_CODE_NOT_FOUND', false); } else { this.updateCart(element); console.log('Dealer code is valid.'); } }, error => { // element.value = null; this.customerModel.dealerCode = ''; this.sharedService.showSpinner(false); // spinner this.sharedService.showErrorMessage(error, true); console.error('error=>' + error) }); } else { this.sharedService.showErrorMessage('VALIDATEDEALER_ERROR_CODE_2009', false); } } /** * This function is used to create customer using customer service and update in the cart. * @returns void */ saveCustomerProfile(): void { const METHOD_NAME: string = 'saveCustomerProfile()'; // console.log('Saving the customer profile.'); if (this.cart && this.customerModel.firstName && this.customerModel.lastName && this.customerModel.address1 && this.customerModel.city && this.customerModel.state && this.customerModel.zipCode && this.customerModel.phone1) { const inputData: any = { orderId: this.cart.orderId, firstName: this.customerModel.firstName, lastName: this.customerModel.lastName, middleName: this.customerModel.middleName, address1: this.customerModel.address1, address2: this.customerModel.address2, city: this.customerModel.city, state: this.customerModel.state, zipCode: this.customerModel.zipCode, phone1: this.customerModel.phone1, email1: this.customerModel.email1, nonTMOMobilePin:this.customerModel.nonTMOMobilePin, nonTMOMobileNumber:this.customerModel.nonTMOMobileNumber } inputData.phone1 = Utils.nonFormatPhoneNumber(this.customerModel.phone1); this.sharedService.showSpinner(true); // spinner if (this.cart.customer) { this.cart.customer = Object.assign(this.cart.customer, inputData); } else { this.cart.customer = inputData; } this.cartService.setCart(this.cart); // setting before so that accessory flow we are not getting the customer values refer QC 495591 this.customerService.createCustomer(this.storeId, inputData).subscribe(result => { this.KarmaTestResult = result; this.sharedService.showSpinner(false); // spinner this.cart.customer.addressId = result.addressId; this.cartService.setCart(this.cart); }, error => { this.sharedService.showSpinner(false); // spinner console.error('error=>' + error); this.sharedService.showErrorMessage(error, true); }); } } /**update cart with web order#,company name, copr node and dealer code */ /** * This function is used to update cart with web order#, * company name, copr node and dealer code * @param {any} element * @returns void */ updateCart(element: any): void { const METHOD_NAME: string = 'updateCart()'; console.log('CustomerComponent.updateCart' + element); if (element && (element.valid  ||  element.isDisabled) && element.value) { if (!this.cart) { const inputData: any = CartUtils.createCartInput(this.storeId, this.user); this.sharedService.showSpinner(true); // spinner this.cartService.createCartDetails(this.storeId, inputData).subscribe(result => { this.sharedService.showSpinner(false); // spinner this.cart = result; // this.cartService.setCart(result); if (this.customer) { this.customer.orderId = this.cart.orderId; this.sharedService.showSpinner(true); // spinner this.customerService.createCustomer(this.storeId, this.customer).subscribe(createCustomerResult => { this.sharedService.showSpinner(false); // spinner this.cart.customer = Object.assign({}, this.customer); this.cart.customer.addressId = createCustomerResult.addressId; this.customer = null; this.customerService.setCustomer(null); // this.cart.customer = this.customer; // this.cartService.setCart(this.cart); console.log('Successfully added.'); this.updateCart(element); }, error => { this.sharedService.showSpinner(false); // spinner this.sharedService.showErrorMessage(error, true); console.error('error=>' + error) }); } else { this.updateCart(element); } }, error => { this.sharedService.showSpinner(false); // spinner console.error('error=>' + error); this.sharedService.showErrorMessage(error, true); }); } else { console.log('this.cart[element.name]:' + this.cart[element.name]); if (!this.cart[element.name] || (this.cart[element.name] !== element.value)) { const inputData = {}; inputData[element.name] = element.value; this.sharedService.showSpinner(true); // spinner this.cartService.updateCartDetails(this.storeId, this.cart.orderId, inputData).subscribe(result => { this.sharedService.showSpinner(false); // spinner this.cartService.setCart(Object.assign(this.cart, result)); }, error => { this.sharedService.showSpinner(false); // spinner console.error('error=>' + error); this.sharedService.showErrorMessage(error, true); }); } } } } /** * This function is used to save fields * where there is customer data entered by agent * @param {any} element * @returns void */ saveFields(element: any): void { const METHOD_NAME: string = 'saveFields()'; console.log('CustomerComponent.saveFields' + element); if (element && element.valid && element.value && this.cart && this.cart.customer) { const customer: Customer = this.cart.customer; if (customer && (!customer[element.name] || (customer[element.name] !== element.value))) { if (element.name === Constants.CUSTOMER_PHONE ) { const val = element.value.replace(new RegExp('-', 'g'), ''); if (customer[element.name] && customer[element.name] !== val) { this.saveCustomerProfile(); } } else { this.saveCustomerProfile(); } } } } /** * This function is used to update creditType * @param {string} type * @returns void */ acceptCreditSwitch(type: string): void { const METHOD_NAME: string = 'acceptCreditSwitch()'; this.hasItemsInCart = false; this.conflictModel.hide(); (type === 'Continue') ? this.updateCreditType(this.cart.orderId, this.creditType) : this.revertBackCreditType(this.creditType); } /** key press handler event */ /** * This function is used to prevent the user enter to enter charactes by using keypress handler. * @param {} event * @returns void */ keypresshandler(event): void { const METHOD_NAME: string = 'keypresshandler()'; const charCode = event.keyCode; if (charCode > 31 && (charCode < 48 || charCode > 57)) { event.preventDefault(); } } validatePOAdress(address: any): void { this.hasPOAddress = (address && address.match(/P[\.\s]*O[\.\s]*Box/igm)) ? true : false; } //US335007 As a DASH dev I want UI changes for promotional information displayed when a //configured Zip code is entered in Customer Information so that I can offer it to my customer /** * This function is used to check if the zip code has eligible promotions. * @param {any} element * @returns void */ isZipCodePromoEligible(): void { const METHOD_NAME: string = 'isZipCodePromoEligible()'; if ((this.customerModel && this.customerModel.zipCode && this.customerModel.zipCode.length == 5) || (this.customer && this.customer.zipCode && this.customer.zipCode.length == 5)) { console.log(this.customerModel.zipCode); this.sharedService.addLogging(this.COMPONENT_NAME, METHOD_NAME, 'Zip Code Promotion eligibility'); const userId = this.userService.getUser().userId; //this.sharedService.showSpinner(true); // spinner //not required this.customerService.zipCodePromotion(this.storeId, this.customerModel.zipCode).subscribe(result => { //this.sharedService.showSpinner(false); // spinner //not required if (result && result.promotions && result.promotions.length > 0) { console.log('setting zip code promotion eligibility from the api response.'); if (this.customer) { this.customer.isPromoEligibleZipCode = true; } else { this.customerModel.isPromoEligibleZipCode = true; this.customerService.setCustomerModel(this.customerModel); } } }, error => { //this.sharedService.showSpinner(false); // spinner //not required //this.sharedService.showErrorMessage(error, true); console.error('error=>' + error) }); } } // /** // * This function is used to validate pin and phonenumber using user service. // * @param {any} element // * @returns void // */ validateEligibility(nonTMOMobileNumber,nonTMOMobilePin):void{ this.eligibilityReq = new CreditEligibilityReq(); this.sharedService.showSpinner(true); // spinner this.eligibilityReq.pin = this.customerModel.nonTMOMobilePin; //console.log(this.eligibilityReq.pin); if(this.customerModel && this.customerModel.nonTMOMobileNumber) this.eligibilityReq.subscriberNumber = this.customerModel.nonTMOMobileNumber.replace(new RegExp('-', 'g'), ''); this.eligibilityReq.orderId = this.customerModel.orderId; //this.customerService.verifyEligibility( this.req).subscribe( this.customerService.verifyEligibility(this.storeId, this.eligibilityReq).subscribe( response =>{ this.sharedService.showSpinner(false); // spinner console.log(response); if (response && response.overallEligibility && response.overallEligibility == 'y') { this.customerModel.isValidated = true; this.customerModel.eligibilityMsg = Utils.getErrorValue('_SUCCESS_MSG'); this.eligibilityMsg = Utils.getErrorValue('_SUCCESS_MSG'); this.customerModel.eligibilityDate = response.nextEligibilityDate; this.customerModel.eligibility = response.overallEligibility; this.customerModel.nonTMOMobileNumber = response.subscriberNumber; this.customerModel.accountNumber = response.accountNumber; this.customerModel.brandType = response.accountType; this.customerModel.accountNumber = response.accountNumber; if(response.consecutivePaymentCount && response.consecutivePaymentCount !='') this.customerModel.paymentCount = response.consecutivePaymentCount; else this.customerModel.paymentCount = 0; } else { this.customerModel.isValidated = false; } if(response.errorMessage) this.eligibilityErrorMsg = response.errorMessage; }, error => { this.sharedService.showSpinner(false); console.log(error); this.eligibilityErrorMsg = this.sharedService.getErrorMessage(error); }); } // /** // * This function is used to enable Existing phone number & Prepaid pin input fields. // * @returns void // */ onResetForm():void{ this.customerModel.isValidated = false; this.eligibilityErrorMsg = ""; } }