Skip to content

Commit

Permalink
Remove confirm unamend
Browse files Browse the repository at this point in the history
  • Loading branch information
sasha-dresden committed Aug 23, 2024
1 parent 71cb97e commit 76b74ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ describe('ReportListComponent', () => {
});

describe('unamend', () => {
it('should call confirm', () => {
const confirmSpy = spyOn(component.confirmationService, 'confirm');
component.confirmUnamend(testActiveReport);
expect(confirmSpy).toHaveBeenCalledTimes(1);
});

it('should hit service', () => {
const unamendSpy = spyOn(reportService, 'startUnamendment').and.returnValue(of(''));
component.unamendReport({ id: '999' } as Report);
Expand Down
21 changes: 7 additions & 14 deletions front-end/src/app/reports/report-list/report-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class ReportListComponent extends TableListBaseComponent<Report> implemen
(report: Report) => report.report_status !== ReportStatus.IN_PROGRESS,
),
new TableAction('Delete', this.confirmDelete.bind(this), (report: Report) => report.can_delete),
new TableAction('Unamend', this.confirmUnamend.bind(this), (report: Report) => report.can_unamend),
new TableAction('Unamend', this.unamendReport.bind(this), (report: Report) => report.can_unamend),
new TableAction('Download as .fec', this.download.bind(this)),
];

Expand Down Expand Up @@ -108,25 +108,18 @@ export class ReportListComponent extends TableListBaseComponent<Report> implemen
});
}

public confirmUnamend(report: Report): void {
this.confirmationService.confirm({
message: 'Are you sure you want to unamend this amendent? This action cannot be undone.',
header: 'Hang on...',
rejectLabel: 'Cancel',
rejectIcon: 'none',
rejectButtonStyleClass: 'p-button-secondary',
acceptLabel: 'Confirm',
acceptIcon: 'none',
accept: async () => this.unamendReport(report),
});
}

async unamendReport(report: Report) {
this.itemService
.startUnamendment(report)
.pipe(take(1), takeUntil(this.destroy$))
.subscribe(() => {
this.loadTableItems({});
this.messageService.add({
severity: 'success',
summary: 'Successful',
detail: 'Report Unamended',
life: 3000,
});
});
}

Expand Down

0 comments on commit 76b74ef

Please sign in to comment.