import { Component, OnInit } from '@angular/core';
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
import { EitService } from '../services/eit.service';

@Component({
  selector: 'app-cei-homepage',
  templateUrl: './cei-homepage.component.html',
  styleUrls: ['./cei-homepage.component.scss'],
})
export class CeiHomepageComponent implements OnInit {

  public familyMemberData;
  public selectedServiceType;
  public direction: string;
  myColor: string = 'secondary';
  constructor(
    private eitService: EitService,
    public ts: TranslatorService,
    public cs: CommonService
    ) {}


  ngOnInit() {
    this.getContactInfo();
  }

  public getContactInfo () {
    this.eitService.getContactInfo({
      P_MENU_TYPE: 'E',
      P_SELECTED_RESP_ID: -999
    }, () => { }, this.ts.trPK('general', 'retry')).subscribe((response) => {
      if (this.cs.validResponse(response)) {
        this.familyMemberData = response['GetEmployeeContactsList'];
        this.selectedServiceType = this.familyMemberData[0];
        console.log(this.familyMemberData);
      }
    });
  }

  public gotoTransactionsPage() {
    console.log(this.selectedServiceType);
    this.cs.sharedService.setSharedData(this.selectedServiceType, 'selectedContactFORChildEducation');
    this.cs.openCEIListPage();
  }

  public selectedUser(user){
    this.selectedServiceType = user;
  }

}
