Skip to content

Commit afd483c

Browse files
authored
Merge pull request #1989 from bcgov/bugfix/ALCS-2385-2
Fix Submission Review Error for Non-Authorized Users
2 parents 4de6610 + 0d241ac commit afd483c

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

portal-frontend/src/app/features/applications/review-submission/review-submission.component.ts

+23-12
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export class ReviewSubmissionComponent implements OnInit, OnDestroy {
5757
isOnLastStep = false;
5858
isDeactivating = false;
5959
isLfng = false;
60+
isAllowed = false;
6061

6162
@ViewChild('cdkStepper') public customStepper!: CustomStepperComponent;
6263

@@ -90,9 +91,7 @@ export class ReviewSubmissionComponent implements OnInit, OnDestroy {
9091
const fileId = paramMap.get('fileId');
9192
if (fileId) {
9293
if (this.fileId !== fileId) {
93-
this.loadApplication(fileId);
94-
this.loadApplicationDocuments(fileId);
95-
this.loadApplicationReview(fileId);
94+
this.handleApplication(fileId);
9695
}
9796

9897
this.fileId = fileId;
@@ -119,28 +118,40 @@ export class ReviewSubmissionComponent implements OnInit, OnDestroy {
119118

120119
this.$application.pipe(takeUntil(this.$destroy)).subscribe((application) => {
121120
this.application = application;
122-
123-
if (
124-
(application?.status.code &&
125-
![SUBMISSION_STATUS.IN_REVIEW_BY_LG, SUBMISSION_STATUS.RETURNED_TO_LG].includes(application?.status.code)) ||
126-
!this.isLfng
127-
) {
128-
this.toastService.showErrorToast('Reviewing is not allowed. Please contact ALC for more details');
129-
this.router.navigate(['/home']);
130-
}
131121
});
132122

133123
this.applicationReviewService.$applicationReview.pipe(takeUntil(this.$destroy)).subscribe((appReview) => {
134124
this.isFirstNationGovernment = appReview?.isFirstNationGovernment ?? false;
135125
});
136126
}
137127

128+
async handleApplication(fileId: string) {
129+
await this.loadApplication(fileId);
130+
if (this.isAllowed) {
131+
this.loadApplicationDocuments(fileId);
132+
this.loadApplicationReview(fileId);
133+
}
134+
}
135+
138136
async loadApplicationReview(fileId: string) {
139137
await this.applicationReviewService.getByFileId(fileId);
140138
}
141139

142140
async loadApplication(fileId: string) {
143141
const application = await this.applicationService.getByFileId(fileId);
142+
143+
if (
144+
(application?.status.code &&
145+
![SUBMISSION_STATUS.IN_REVIEW_BY_LG, SUBMISSION_STATUS.RETURNED_TO_LG].includes(application?.status.code)) ||
146+
!this.isLfng
147+
) {
148+
this.toastService.showErrorToast('Reviewing is not allowed. Please contact ALC for more details');
149+
this.isAllowed = false;
150+
this.router.navigate(['/home']);
151+
return;
152+
}
153+
154+
this.isAllowed = true;
144155
this.$application.next(application);
145156
}
146157

0 commit comments

Comments
 (0)