Skip to content

Commit

Permalink
feat: Move resubmit to platform (#3117)
Browse files Browse the repository at this point in the history
  • Loading branch information
bistaastha authored Jun 28, 2024
1 parent 54af1b1 commit fa61bc5
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 24 deletions.
13 changes: 13 additions & 0 deletions src/app/core/services/platform/v1/spender/reports.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ describe('SpenderReportsService', () => {
});
});

it('resubmit(): should resubmit a report', (done) => {
spenderPlatformV1ApiService.post.and.returnValue(of(null));

const reportID = 'rpvcIMRMyM3A';

spenderReportsService.resubmit(reportID).subscribe(() => {
expect(spenderPlatformV1ApiService.post).toHaveBeenCalledOnceWith(`/reports/resubmit`, {
data: { id: reportID },
});
done();
});
});

it('postComment(): should add a comment', (done) => {
const expectedCommentData: Comment = platformReportData.comments[0];
spenderPlatformV1ApiService.post.and.returnValue(of({ data: expectedCommentData }));
Expand Down
4 changes: 4 additions & 0 deletions src/app/core/services/platform/v1/spender/reports.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ export class SpenderReportsService {
return this.spenderPlatformV1ApiService.post<void>('/reports/submit', { data: { id: reportId } });
}

resubmit(reportId: string): Observable<void> {
return this.spenderPlatformV1ApiService.post<void>('/reports/resubmit', { data: { id: reportId } });
}

getAllReportsByParams(queryParams: ReportsQueryParams): Observable<Report[]> {
return this.getReportsCount(queryParams).pipe(
switchMap((count) => {
Expand Down
10 changes: 0 additions & 10 deletions src/app/core/services/report.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,6 @@ describe('ReportService', () => {
});
});

it('resubmit(): should resubmit a report', (done) => {
apiService.post.and.returnValue(of(null));

const reportID = 'rpShFuVCUIXk';
reportService.resubmit(reportID).subscribe(() => {
expect(apiService.post).toHaveBeenCalledOnceWith(`/reports/${reportID}/resubmit`);
done();
});
});

it('inquire(): should send back a report', (done) => {
apiService.post.and.returnValue(of(null));
const reportID = 'rpSECyvCyyc6';
Expand Down
7 changes: 0 additions & 7 deletions src/app/core/services/report.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ export class ReportService {
return this.transactionService.clearCache();
}

@CacheBuster({
cacheBusterNotifier: reportsCacheBuster$,
})
resubmit(rptId: string): Observable<void> {
return this.apiService.post('/reports/' + rptId + '/resubmit');
}

@CacheBuster({
cacheBusterNotifier: reportsCacheBuster$,
})
Expand Down
2 changes: 1 addition & 1 deletion src/app/fyle/my-view-report/my-view-report.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
>{{report.created_at | date: 'MMM dd, YYYY'}}</span
>
<span *ngIf="report.state !== 'DRAFT'" class="view-reports--submitted-date__date"
>{{report.last_submitted_at | date: 'MMM dd, YYYY'}}</span
>{{(report.last_resubmitted_at || report.last_submitted_at) | date: 'MMM dd, YYYY'}}</span
>
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/app/fyle/my-view-report/my-view-report.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ describe('MyViewReportPage', () => {
'permissions',
'postComment',
'submit',
'resubmit',
]);

TestBed.configureTestingModule({
Expand Down Expand Up @@ -616,14 +617,14 @@ describe('MyViewReportPage', () => {
},
duration: 3000,
};
reportService.resubmit.and.returnValue(of(null));
spenderReportsService.resubmit.and.returnValue(of(null));
matSnackBar.openFromComponent.and.callThrough();
snackbarProperties.setSnackbarProperties.and.returnValue(properties);

const resubmitButton = getElementBySelector(fixture, '.fy-footer-cta--primary') as HTMLElement;
click(resubmitButton);

expect(reportService.resubmit).toHaveBeenCalledWith(component.reportId);
expect(spenderReportsService.resubmit).toHaveBeenCalledWith(component.reportId);
expect(refinerService.startSurvey).toHaveBeenCalledOnceWith({ actionName: 'Resubmit Report ' });
expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'enterprise', 'my_reports']);
expect(matSnackBar.openFromComponent).toHaveBeenCalledOnceWith(ToastMessageComponent, {
Expand Down
2 changes: 1 addition & 1 deletion src/app/fyle/my-view-report/my-view-report.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export class MyViewReportPage {
}

resubmitReport(): void {
this.reportService.resubmit(this.reportId).subscribe(() => {
this.spenderReportsService.resubmit(this.reportId).subscribe(() => {
this.refinerService.startSurvey({ actionName: 'Resubmit Report ' });
this.router.navigate(['/', 'enterprise', 'my_reports']);
const message = `Report resubmitted successfully.`;
Expand Down
2 changes: 1 addition & 1 deletion src/app/fyle/view-team-report/view-team-report.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<div>
<span class="view-reports--submitted-date__text">Submitted on: </span>
<span class="view-reports--submitted-date__date"
>{{report.last_submitted_at | date: 'MMM dd, YYYY'}}</span
>{{(report.last_resubmitted_at || report.last_submitted_at) | date: 'MMM dd, YYYY'}}</span
>
</div>
</div>
Expand Down
2 changes: 0 additions & 2 deletions src/app/fyle/view-team-report/view-team-report.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { SnackbarPropertiesService } from 'src/app/core/services/snackbar-proper
import { StatusService } from 'src/app/core/services/status.service';
import { orgSettingsData } from 'src/app/core/test-data/accounts.service.spec.data';
import {
expectedNewStatusData,
newEstatusData1,
systemComments1,
systemCommentsWithSt,
Expand All @@ -45,7 +44,6 @@ import { NetworkService } from '../../core/services/network.service';
import { TrackingService } from '../../core/services/tracking.service';
import { ShareReportComponent } from './share-report/share-report.component';
import { ViewTeamReportPage } from './view-team-report.page';
import { txnStatusData } from 'src/app/core/mock-data/transaction-status.data';
import { pdfExportData1, pdfExportData2 } from 'src/app/core/mock-data/pdf-export.data';
import { EditReportNamePopoverComponent } from '../my-view-report/edit-report-name-popover/edit-report-name-popover.component';
import { cloneDeep } from 'lodash';
Expand Down

0 comments on commit fa61bc5

Please sign in to comment.