|
@@ -1,10 +1,57 @@
|
|
|
-import { Component } from '@angular/core';
|
|
|
+import { Component, OnInit } from '@angular/core';
|
|
|
+import {
|
|
|
+ FormGroup,
|
|
|
+ UntypedFormControl,
|
|
|
+ UntypedFormGroup,
|
|
|
+ Validators,
|
|
|
+} from '@angular/forms';
|
|
|
+import { Router } from '@angular/router';
|
|
|
+import { BaseForm } from '@core/base/base-form';
|
|
|
+import { ComponentBase } from '@core/base/common-base';
|
|
|
+import { AuthService } from '@core/services/authentication/auth.service';
|
|
|
+import { ToastrService } from 'ngx-toastr';
|
|
|
+import { takeUntil } from 'rxjs';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-change-password',
|
|
|
templateUrl: './change-password.component.html',
|
|
|
- styleUrls: ['./change-password.component.scss']
|
|
|
+ styleUrls: ['./change-password.component.scss'],
|
|
|
})
|
|
|
-export class ChangePasswordComponent {
|
|
|
+export class ChangePasswordComponent
|
|
|
+ extends ComponentBase
|
|
|
+ implements BaseForm, OnInit
|
|
|
+{
|
|
|
+ form!: FormGroup;
|
|
|
|
|
|
+ constructor(
|
|
|
+ private readonly router: Router,
|
|
|
+ private readonly toastr: ToastrService,
|
|
|
+ private readonly authSer: AuthService
|
|
|
+ ) {
|
|
|
+ super();
|
|
|
+ }
|
|
|
+
|
|
|
+ ngOnInit(): void {
|
|
|
+ this.initForm();
|
|
|
+ }
|
|
|
+
|
|
|
+ initForm(): void {
|
|
|
+ this.form = new UntypedFormGroup({
|
|
|
+ password: new UntypedFormControl(null, [Validators.required]),
|
|
|
+ confirm_password: new UntypedFormControl(null, [Validators.required]),
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ onSubmit(): void {
|
|
|
+ if (super.submitValidity(this.form)) {
|
|
|
+ this.authSer
|
|
|
+ .ChnagePassword(this.form.value)
|
|
|
+ .pipe(takeUntil(this.destroy$))
|
|
|
+ .subscribe((res) => {
|
|
|
+ console.log('res => ', res);
|
|
|
+ this.toastr.success('Password Changes Successfully');
|
|
|
+ this.router.navigate(['/']);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|