Skip to content

Commit

Permalink
chore: improve text, small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
illfixit committed Jun 11, 2024
1 parent 1affc5d commit 524f215
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 mat-dialog-title>Terms of data offer</h1>
<h1 mat-dialog-title>Data Offer Terms & Conditions</h1>

<div mat-dialog-content>
<p>
Expand All @@ -10,7 +10,7 @@ <h1 mat-dialog-title>Terms of data offer</h1>

<div class="w-full flex flex-col justify-center">
<mat-checkbox [checked]="checkboxChecked" (change)="onCheckboxChange($event)">
I agree to the Terms of data offer
I agree to the Data Offer Terms & Conditions
</mat-checkbox>

<div class="w-full flex flex-row justify-end" mat-dialog-actions>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, OnInit} from '@angular/core';
import {Component} from '@angular/core';
import {MatCheckboxChange} from '@angular/material/checkbox';
import {MatDialogRef} from '@angular/material/dialog';

Expand All @@ -7,15 +7,13 @@ import {MatDialogRef} from '@angular/material/dialog';
templateUrl: './initiate-transfer-confirm-tos-dialog.component.html',
styleUrls: ['./initiate-transfer-confirm-tos-dialog.component.scss'],
})
export class InitiateTransferConfirmTosDialogComponent implements OnInit {
export class InitiateTransferConfirmTosDialogComponent {
checkboxChecked = false;

constructor(
public dialogRef: MatDialogRef<InitiateTransferConfirmTosDialogComponent>,
) {}

ngOnInit(): void {}

public onCheckboxChange($event: MatCheckboxChange) {
this.checkboxChecked = $event.checked;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,44 +97,48 @@ export class ContractAgreementTransferDialogComponent implements OnDestroy {

const confirmationDialogRef = this.confirmationDialog.open(
InitiateTransferConfirmTosDialogComponent,
{maxWidth: '30%'},
{maxWidth: '30rem'},
);

confirmationDialogRef.afterClosed().subscribe((result) => {
if (result) {
this.loading = true;
this.form.all.disable();

const value = this.form.value;
let request$: Observable<IdResponseDto>;
if (value.dataAddressType === 'Custom-Transfer-Process-Request') {
const request = this.buildCustomTransferRequest(value);
request$ = this.edcApiService.initiateCustomTransfer(request);
} else {
const request = this.buildTransferRequest(value);
request$ = this.edcApiService.initiateTransfer(request);
}

request$
.pipe(
finalize(() => {
this.loading = false;
this.form.all.enable();
}),
)
.subscribe({
next: (response) =>
this.close({
transferProcessId: response.id!,
contractId: this.data.contractId,
}),
error: (err) => {
this.notificationService.showError('Failed initiating transfer!');
console.error('Failed initiating transfer', err);
},
});
confirmationDialogRef
.afterClosed()
.subscribe((result) => this.initiateTransfer(result));
}

private initiateTransfer(result: boolean) {
if (result) {
this.loading = true;
this.form.all.disable();

const value = this.form.value;
let request$: Observable<IdResponseDto>;
if (value.dataAddressType === 'Custom-Transfer-Process-Request') {
const request = this.buildCustomTransferRequest(value);
request$ = this.edcApiService.initiateCustomTransfer(request);
} else {
const request = this.buildTransferRequest(value);
request$ = this.edcApiService.initiateTransfer(request);
}
});

request$
.pipe(
finalize(() => {
this.loading = false;
this.form.all.enable();
}),
)
.subscribe({
next: (response) =>
this.close({
transferProcessId: response.id!,
contractId: this.data.contractId,
}),
error: (err) => {
this.notificationService.showError('Failed initiating transfer!');
console.error('Failed initiating transfer', err);
},
});
}
}

private close(params: ContractAgreementTransferDialogResult) {
Expand Down

0 comments on commit 524f215

Please sign in to comment.