Skip to content

Commit

Permalink
fix: soc
Browse files Browse the repository at this point in the history
  • Loading branch information
illfixit committed Jun 12, 2024
1 parent 524f215 commit 5ab6e5e
Showing 1 changed file with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,45 +100,45 @@ export class ContractAgreementTransferDialogComponent implements OnDestroy {
{maxWidth: '30rem'},
);

confirmationDialogRef
.afterClosed()
.subscribe((result) => this.initiateTransfer(result));
confirmationDialogRef.afterClosed().subscribe((result) => {
if (result) {
this.initiateTransfer();
}
});
}

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

private close(params: ContractAgreementTransferDialogResult) {
Expand Down

0 comments on commit 5ab6e5e

Please sign in to comment.