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-deductions',
  templateUrl: './deductions.component.html',
  styleUrls: ['./deductions.component.scss'],
})
export class DeductionsComponent implements OnInit {
  actionContextID:any;
  GetDeductionsList: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.getDeduction(this.actionContextID );
  }


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

  handleGetDeductionResult(result){
    if (result.GetDeductionsList != null) {
      this.GetDeductionsList = result.GetDeductionsList;
    }
  }

}
