import { Component, Inject, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { NanoDialogBase } from 'src/app/shared/dialogs/nano-base-dialog';
import { PaymentService } from 'src/app/shared/server-services/payment.service';
import { PaymentBillingsRecord } from 'src/app/shared/server-services/query-records/payment-records';
import { DialogService } from 'src/app/shared/services/dialog.service';
import { marker } from "@biesbjerg/ngx-translate-extract-marker";

@Component({
  selector: 'app-edit-billing-template-dialog',
  templateUrl: './edit-billing-template-dialog.component.html',
  styleUrls: ['./edit-billing-template-dialog.component.scss']
})
export class EditBillingTemplateDialogComponent extends NanoDialogBase<EditBillingTemplateDialogComponent> implements OnInit  {

  paymentBillings: PaymentBillingsRecord[];

  constructor(
    public dialogRef: MatDialogRef<EditBillingTemplateDialogComponent>,
    public dialogService: DialogService,
    public paymentService: PaymentService,
    @Inject(MAT_DIALOG_DATA) paymentBillings: PaymentBillingsRecord[]) { 
      super(dialogRef);
      this.paymentBillings = paymentBillings;
    }

  ngOnInit(): void {
  }

  public deleteBillings(selectedBillings: any): void{
    var toDeleteBillingIds = selectedBillings.map(s => s.value);

    this.dialogService.openConfirmDialog(marker("Delete billing templates"), marker("Are you sure you want to delete the selected billing templates?"))
      .subscribe(confirm => {
        if(!confirm) return;

        this.dialogRef.close(toDeleteBillingIds);
      });
  }

}
