1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-06 10:33:57 +00:00

PM-4960 Migrate Verify Recover Delete Component (#9171)

* PM-4960 Migrate Verify Recover Delete Component

* PM-4960 Minor fix

* PM-4960 Addressed review comments
This commit is contained in:
KiruthigaManivannan
2024-06-19 20:48:31 +05:30
committed by GitHub
parent a427ec371a
commit dfd4479a9c
3 changed files with 41 additions and 61 deletions

View File

@@ -1,11 +1,11 @@
import { Component, OnInit } from "@angular/core";
import { FormGroup } from "@angular/forms";
import { ActivatedRoute, Router } from "@angular/router";
import { first } from "rxjs/operators";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { VerifyDeleteRecoverRequest } from "@bitwarden/common/models/request/verify-delete-recover.request";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
@Component({
@@ -15,10 +15,10 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class VerifyRecoverDeleteComponent implements OnInit {
email: string;
formPromise: Promise<any>;
private userId: string;
private token: string;
protected formGroup = new FormGroup({});
constructor(
private router: Router,
@@ -26,7 +26,6 @@ export class VerifyRecoverDeleteComponent implements OnInit {
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private route: ActivatedRoute,
private logService: LogService,
) {}
ngOnInit() {
@@ -37,28 +36,19 @@ export class VerifyRecoverDeleteComponent implements OnInit {
this.token = qParams.token;
this.email = qParams.email;
} else {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.router.navigate(["/"]);
await this.router.navigate(["/"]);
}
});
}
async submit() {
try {
const request = new VerifyDeleteRecoverRequest(this.userId, this.token);
this.formPromise = this.apiService.postAccountRecoverDeleteToken(request);
await this.formPromise;
this.platformUtilsService.showToast(
"success",
this.i18nService.t("accountDeleted"),
this.i18nService.t("accountDeletedDesc"),
);
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.router.navigate(["/"]);
} catch (e) {
this.logService.error(e);
}
}
submit = async () => {
const request = new VerifyDeleteRecoverRequest(this.userId, this.token);
await this.apiService.postAccountRecoverDeleteToken(request);
this.platformUtilsService.showToast(
"success",
this.i18nService.t("accountDeleted"),
this.i18nService.t("accountDeletedDesc"),
);
await this.router.navigate(["/"]);
};
}