import { Component , Input } from '@angular/core' ; import { Router } from '@angular/router' ; import { CreateService } from '../../create.service' ; import { NotifierService } from 'angular-notifier' ; import { I18nService } from '../../../../layout/components/i18n/i18n.service' ; @ Component ( { selector : 'app-account-create-pin' , styleUrls : [ './pin.component.scss' ] , templateUrl : './pin.component.html' } ) export class AccountCreatePinComponent { @ Input ( ) lastStep : boolean ; pin : string ; constructor ( private router , private createService , private notificationService , private i18nService ) { } public back ( ) { this . createService . previousStep ( ) ; } public next ( ) { if ( ! this . isValid ) { return ; } this . createService . setPin ( this . pin ) ; setTimeout ( ( ) => { this . createService . nextStep ( ) ; } , 0 ) ; } public get isValid ( ) : boolean { return this . pin && this . pin . length >= 4 ; } public finish ( ) { if ( ! this . isValid ) { return ; } this . createService . setPin ( this . pin ) ; this . createService . createActiveAccount ( ) . then ( ( success ) => { this . notificationService . notify ( 'success' , this . i18nService . getTranslation ( 'account_added' ) ) ; this . createService . reset ( ) ; this . router . navigate ( [ '/' ] ) ; } , ( error ) => { this . notificationService . notify ( 'error' , error . toString ( ) ) ; } ) ; } }