/** Angular Imports */ import { Component , OnInit } from '@angular/core' ; import { ActivatedRoute , Router } from '@angular/router' ; import { MatDialog } from '@angular/material/dialog' ; /** Custom Services */ import { ProductsService } from 'app/products/products.service' ; /** Custom Components */ import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component' ; /**
 * View Charge Component.
 */ @ Component ( { selector : 'mifosx-view-charge' , templateUrl : './view-charge.component.html' , styleUrls : [ './view-charge.component.scss' ] } ) export class ViewChargeComponent implements OnInit { /** Charge data. */ chargeData : any ; param { ProductsService } productsService param { ActivatedRoute } route param { Router } router param { MatDialog } dialog constructor ( private productsService , private route , private router , private dialog ) { this . route . data . subscribe ( ( data ) => { this . chargeData = data . charge ; } ) ; } ngOnInit ( ) { } /**
     * Deletes the charge and redirects to charges.
     */ deleteCharge ( ) { const deleteChargeDialogRef = this . dialog . open ( DeleteDialogComponent , { data : { deleteContext : `charge ${ this . chargeData . id }` } } ) ; deleteChargeDialogRef . afterClosed ( ) . subscribe ( ( response ) => { if ( response . delete ) { this . productsService . deleteCharge ( this . chargeData . id ) . subscribe ( ( ) => { this . router . navigate ( [ '/products/charges' ] ) ; } ) ; } } ) ; } }