/** Angular Imports */ import { Component , OnInit } from '@angular/core' ; import { FormGroup , FormBuilder , Validators } from '@angular/forms' ; import { DatePipe } from '@angular/common' ; import { ActivatedRoute , Router } from '@angular/router' ; /** Custom Services */ import { SavingsService } from 'app/savings/savings.service' ; import { SettingsService } from 'app/settings/settings.service' ; /**
 * Activate Fixed Deposits Account Component
 */ @ Component ( { selector : 'mifosx-activate-fixed-deposits-account' , templateUrl : './activate-fixed-deposits-account.component.html' , styleUrls : [ './activate-fixed-deposits-account.component.scss' ] } ) export class ActivateFixedDepositsAccountComponent implements OnInit { /** Minimum date allowed. */ minDate = new Date ( 2000 , 0 , 1 ) ; /** Maximum date allowed. */ maxDate = new Date ( ) ; /** Activate Fixed Deposits Account form. */ activateFixedDepositsAccountForm : FormGroup ; /** Fixed Deposits Account Id */ accountId : any ; param { FormBuilder } formBuilder param { SavingsService } savingsService param { DatePipe } datePipe param { ActivatedRoute } route param { Router } router param { SettingsService } settingsService constructor ( private formBuilder , private savingsService , private datePipe , private route , private router , private settingsService ) { this . accountId = this . route . parent . snapshot . params [ 'fixedDepositAccountId' ] ; } /**
     * Creates the activate fixed deposits form.
     */ ngOnInit ( ) { this . createActivateFixedDepositsAccountForm ( ) ; } /**
     * Creates the activate fixed deposits account form.
     */ createActivateFixedDepositsAccountForm ( ) { this . activateFixedDepositsAccountForm = this . formBuilder . group ( { 'activatedOnDate' : [ '' , Validators . required ] } ) ; } /**
     * Submits the form and activates the fixed deposit account,
     * if successful redirects to the fixed deposit account.
     */ submit ( ) { const locale = this . settingsService . language . code ; const dateFormat = this . settingsService . dateFormat ; const prevActivatedOnDate = this . activateFixedDepositsAccountForm . value . activatedOnDate ; this . activateFixedDepositsAccountForm . patchValue ( { activatedOnDate : this . datePipe . transform ( prevActivatedOnDate , dateFormat ) , } ) ; const data = { ... this . activateFixedDepositsAccountForm . value , dateFormat , locale } ; this . savingsService . executeSavingsAccountCommand ( this . accountId , 'activate' , data ) . subscribe ( ( ) => { this . router . navigate ( [ '../../' ] , { relativeTo : this . route } ) ; } ) ; } }