import { Component, AfterViewInit, OnInit } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; import {ApplicationService} from '../services/application.service'; declare var jQuery: any; @Component({ templateUrl: './app/components/update-password.component.html', styles: [` .child { position: relative; margin-left:20%; margin-right:20%; } @media only screen and (max-width: 700px) { .child { margin-left: 0; margin-right: 0; } } `] }) export class UpdatePasswordComponent implements AfterViewInit { password: string; confirmPassword: string; isProcessing: boolean; message: string; isPasswordResetValidityExpired: boolean; constructor(public application: ApplicationService, private router: Router, private activeRoute: ActivatedRoute) { this.password = ""; this.confirmPassword = ""; this.message = ""; } ngOnInit(): void { this.application.isResetPasswordExpired(this.activeRoute.snapshot.params['userId']).subscribe((response) => { if (!response.successful) { this.isPasswordResetValidityExpired = true; this.message = response.message; setTimeout(() => { this.router.navigate(['/login']); }, 2000); } });; } ngAfterViewInit(): void { jQuery('body').css("background-color", "brown"); } updatePassword(): void { this.isProcessing = true; this.message = ""; if (this.password == this.confirmPassword) { this.application.updatePassword(this.activeRoute.snapshot.params['userId'], this.password).subscribe((response) => { if (response.successful) { this.message = response.message; this.isProcessing = false; setTimeout(() => { this.router.navigate(['/login']); }, 2000); } }); } } }