[PM-7004] Delete formGroup initialization in verify-recover-delete-org.component.ts

This commit is contained in:
Rui Tome 2024-04-19 14:35:33 +01:00
parent 392fdb8a14
commit 0b191a27dd
No known key found for this signature in database
GPG Key ID: 526239D96A8EC066
2 changed files with 35 additions and 41 deletions

View File

@ -1,6 +1,5 @@
<form [formGroup]="formGroup" [bitSubmit]="submit">
<div class="row justify-content-md-center mt-5">
<div class="col-4">
<div class="row justify-content-md-center mt-5">
<div class="col-3">
<p class="lead text-center mb-4">{{ "deleteOrganization" | i18n }}</p>
<div class="card">
<div class="card-body">
@ -17,9 +16,9 @@
<button
type="submit"
bitButton
bitFormButton
buttonType="primary"
class="btn btn-danger btn-block btn-submit"
[bitAction]="submit"
[disabled]="loading"
>
<span>{{ "deleteOrganization" | i18n }}</span>
@ -31,5 +30,4 @@
</div>
</div>
</div>
</div>
</form>
</div>

View File

@ -1,5 +1,4 @@
import { Component, OnInit } from "@angular/core";
import { FormBuilder, FormGroup } from "@angular/forms";
import { ActivatedRoute, Router } from "@angular/router";
import { firstValueFrom } from "rxjs";
@ -20,7 +19,8 @@ export class VerifyRecoverDeleteOrgComponent implements OnInit {
loading = true;
name: string;
protected formGroup: FormGroup;
private orgId: string;
private token: string;
constructor(
private router: Router,
@ -29,16 +29,13 @@ export class VerifyRecoverDeleteOrgComponent implements OnInit {
private i18nService: I18nService,
private route: ActivatedRoute,
private logService: LogService,
private formBuilder: FormBuilder,
) {}
async ngOnInit() {
const qParams = await firstValueFrom(this.route.queryParams);
if (qParams.orgId != null && qParams.token != null && qParams.name != null) {
this.formGroup = this.formBuilder.group({
orgId: [qParams.orgId],
token: [qParams.token],
});
this.orgId = qParams.orgId;
this.token = qParams.token;
this.name = qParams.name;
this.loading = false;
} else {
@ -48,9 +45,8 @@ export class VerifyRecoverDeleteOrgComponent implements OnInit {
submit = async () => {
try {
const { orgId, token } = this.formGroup.value;
const request = new OrganizationVerifyDeleteRecoverRequest(token);
await this.apiService.deleteUsingToken(orgId, request);
const request = new OrganizationVerifyDeleteRecoverRequest(this.token);
await this.apiService.deleteUsingToken(this.orgId, request);
this.platformUtilsService.showToast(
"success",
this.i18nService.t("organizationDeleted"),