
import { Component, OnInit } from '@angular/core';
import {PayslipService} from '../service/payslip.service'
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service';
import { HomeComponent } from '../home/home.component';
@Component({
  selector: 'app-earnings',
  templateUrl: './earnings.component.html',
  styleUrls: ['./earnings.component.scss'],
})
export class EarningsComponent implements OnInit {
  GetEarningsList:any='';
  actionContextID:any;
  constructor(
    public payslipService:PayslipService,
    public ts: TranslatorService,
    public common: CommonService,
    public sharedData: SharedDataService,) {
      this.actionContextID = this.common.sharedService.getSharedData(
        HomeComponent.ACTION_CONTEXT_ID,
        false
      );
     }

  ngOnInit() {
    this.getEarings(this.actionContextID)

  }
  getEarings(ActionContextID){
    const request = {
      P_ACTION_CONTEXT_ID: ActionContextID,
      P_PAGE_NUM: 1,
      P_PAGE_LIMIT: 1000
    };
    
    this.payslipService.getEarings(request, ()=> {} , this.ts.trPK('general', 'retry')).subscribe((result)=> 
    {     
       this.handleGetEaringsResult(result);
    }
    );
  }

  handleGetEaringsResult(result){
    if (result.GetEarningsList != null) {
      this.GetEarningsList = result.GetEarningsList;
    }
  }

}
