@@ -57,6 +57,7 @@ export class ReviewSubmissionComponent implements OnInit, OnDestroy {
57
57
isOnLastStep = false ;
58
58
isDeactivating = false ;
59
59
isLfng = false ;
60
+ isAllowed = false ;
60
61
61
62
@ViewChild ( 'cdkStepper' ) public customStepper ! : CustomStepperComponent ;
62
63
@@ -90,9 +91,7 @@ export class ReviewSubmissionComponent implements OnInit, OnDestroy {
90
91
const fileId = paramMap . get ( 'fileId' ) ;
91
92
if ( fileId ) {
92
93
if ( this . fileId !== fileId ) {
93
- this . loadApplication ( fileId ) ;
94
- this . loadApplicationDocuments ( fileId ) ;
95
- this . loadApplicationReview ( fileId ) ;
94
+ this . handleApplication ( fileId ) ;
96
95
}
97
96
98
97
this . fileId = fileId ;
@@ -119,28 +118,40 @@ export class ReviewSubmissionComponent implements OnInit, OnDestroy {
119
118
120
119
this . $application . pipe ( takeUntil ( this . $destroy ) ) . subscribe ( ( application ) => {
121
120
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
- }
131
121
} ) ;
132
122
133
123
this . applicationReviewService . $applicationReview . pipe ( takeUntil ( this . $destroy ) ) . subscribe ( ( appReview ) => {
134
124
this . isFirstNationGovernment = appReview ?. isFirstNationGovernment ?? false ;
135
125
} ) ;
136
126
}
137
127
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
+
138
136
async loadApplicationReview ( fileId : string ) {
139
137
await this . applicationReviewService . getByFileId ( fileId ) ;
140
138
}
141
139
142
140
async loadApplication ( fileId : string ) {
143
141
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 ;
144
155
this . $application . next ( application ) ;
145
156
}
146
157
0 commit comments