import { Component , OnInit } from '@angular/core' ; import { AccountService } from "../../services/account.service" ; import { Router } from "@angular/router" ; import { UsersService } from "../../services/users/users.service" ; import { ContextService } from "../../services/context.service" ; @ Component ( { selector : 'app-create-account-modal' , templateUrl : './create-account-modal.component.html' , styleUrls : [ './create-account-modal.component.scss' ] , providers : [ AccountService ] } ) export class CreateAccountModalComponent implements OnInit { throwError = false ; showErrorMessage = false ; name : string ; password : string ; email : string ; errorMessage : string ; public showLoader = false ; constructor ( private context , private usersService , private router ) { } ngOnInit ( ) { } createAccount ( ) { this . showLoader = true ; this . usersService . createUser ( this . name , this . password , this . email ) . then ( ( createUserResponse ) => { if ( createUserResponse ) { console . log ( createUserResponse ) ; this . context . setLoginCredentials ( createUserResponse . user . id , createUserResponse . authorization ) ; this . router . navigate ( [ '/base/home/my-groups-section' ] ) ; } else { this . throwError = true ; } this . showLoader = false ; } ) . catch ( ( ) => { this . showLoader = false ; } ) ; } loginLink ( ) { this . router . navigate ( [ '/base/start/login' ] ) ; } }