Add transfer request to transaction reversal.

- Inverts sender and recipient addresses creating a request for transfer from recipient to sender.
This commit is contained in:
Spencer Ofwiti 2021-03-19 17:40:45 +03:00
parent 0668abd62d
commit 71834deadc
2 changed files with 15 additions and 2 deletions

View File

@ -117,7 +117,7 @@
<button mat-raised-button color="primary" type="button" class="btn btn-outline-success">Resend SMS</button>
</div>
<div class="col-md-6">
<button mat-raised-button color="warn" type="button" class="btn btn-outline-danger ml-2">Reverse Transaction</button>
<button mat-raised-button color="warn" type="button" class="btn btn-outline-danger ml-2" (click)="reverseTransaction()">Reverse Transaction</button>
</div>
</div>
</div>

View File

@ -1,5 +1,6 @@
import {ChangeDetectionStrategy, Component, Input, OnInit} from '@angular/core';
import {Router} from '@angular/router';
import {TransactionService} from '@app/_services';
@Component({
selector: 'app-transaction-details',
@ -12,7 +13,10 @@ export class TransactionDetailsComponent implements OnInit {
senderBloxbergLink: string;
recipientBloxbergLink: string;
constructor(private router: Router) { }
constructor(
private router: Router,
private transactionService: TransactionService
) { }
ngOnInit(): void {
this.senderBloxbergLink = 'https://blockexplorer.bloxberg.org/address/' + this.transaction?.from + '/transactions';
@ -26,4 +30,13 @@ export class TransactionDetailsComponent implements OnInit {
async viewRecipient(): Promise<void> {
await this.router.navigateByUrl(`/accounts/${this.transaction.to}`);
}
async reverseTransaction(): Promise<void> {
await this.transactionService.transferRequest(
this.transaction.token.address,
this.transaction.to,
this.transaction.from,
this.transaction.value
);
}
}