import { Component , Injector , OnInit } from '@angular/core' ; import { ActivatedRoute , Router } from '@angular/router' ; import { AppComponentBase } from '@shared/common/app-component-base' ; import { AccountServiceProxy , ActivateEmailInput , ResolveTenantIdInput } from '@shared/service-proxies/service-proxies' ; @ Component ( { template : `<p class="text-center">{{waitMessage}}</p>` } ) export class ConfirmEmailComponent extends AppComponentBase implements OnInit { waitMessage : string ; model : ActivateEmailInput = new ActivateEmailInput ( ) ; constructor ( injector , private _accountService , private _router , private _activatedRoute ) { super ( injector ) ; } ngOnInit ( ) { this . waitMessage = this . l ( 'PleaseWaitToConfirmYourEmailMessage' ) ; this . model . c = this . _activatedRoute . snapshot . queryParams [ 'c' ] ; this . _accountService . resolveTenantId ( new ResolveTenantIdInput ( { c : this . model . c } ) ) . subscribe ( ( tenantId ) => { this . appSession . changeTenantIfNeeded ( tenantId ) ; this . _accountService . activateEmail ( this . model ) . subscribe ( ( ) => { this . notify . success ( this . l ( 'YourEmailIsConfirmedMessage' ) , '' , { onClose : ( ) => { this . _router . navigate ( [ 'account/login' ] ) ; } } ) ; } ) ; } ) ; } parseTenantId ( tenantIdAsStr ? ) { let tenantId = ! tenantIdAsStr ? undefined : parseInt ( tenantIdAsStr , 10 ) ; if ( Number . isNaN ( tenantId ) ) { tenantId = undefined ; } return tenantId ; } }