Skip to content

Commit 0dc1b99

Browse files
committed
ccfri-3756 - add relock AFS to submit appication payload and more code refactor
1 parent f18aa29 commit 0dc1b99

File tree

7 files changed

+207
-93
lines changed

7 files changed

+207
-93
lines changed

frontend/src/components/SummaryDeclaration.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,11 @@ import { useAppStore } from '@/store/app.js';
441441
import { useOrganizationStore } from '@/store/ccof/organization.js';
442442
import { useSummaryDeclarationStore } from '@/store/summaryDeclaration.js';
443443
import { useApplicationStore } from '@/store/application.js';
444+
import { useCcfriAppStore } from '@/store/ccfriApp.js';
444445
import { useReportChangesStore } from '@/store/reportChanges.js';
445446
446447
import {
448+
AFS_STATUSES,
447449
PATHS,
448450
CHANGE_REQUEST_TYPES,
449451
PROGRAM_YEAR_LANGUAGE_TYPES,
@@ -529,6 +531,7 @@ export default {
529531
'isEceweComplete',
530532
'applicationMap',
531533
]),
534+
...mapState(useCcfriAppStore, ['approvableFeeSchedules']),
532535
...mapState(useReportChangesStore, ['changeRequestStore', 'isCREceweComplete', 'isCRLicenseComplete']),
533536
languageYearLabel() {
534537
return this.getLanguageYearLabel;
@@ -809,14 +812,22 @@ export default {
809812
unlockCcfri: facility.unlockCcfri,
810813
unlockNmf: facility.unlockNmf,
811814
unlockRfi: facility.unlockRfi,
815+
unlockAfs: facility.unlockAfs,
812816
};
813817
// Create payload with only unlock propteries set to 1.
814-
815818
unlockPayload = Object.fromEntries(Object.entries(unlockPayload).filter(([_, v]) => v == 1));
816819
// Update payload unlock properties from 1 to 0.
817820
Object.keys(unlockPayload).forEach((key) => {
818821
unlockPayload[key] = '0';
819822
});
823+
824+
const afs = this.approvableFeeSchedules?.find(
825+
(item) => item.ccfriApplicationId === facility.ccfriApplicationId,
826+
);
827+
if (afs?.afsStatus === AFS_STATUSES.UPLOAD_DOCUMENTS) {
828+
unlockPayload.enableAfs = '0';
829+
}
830+
820831
if (Object.keys(unlockPayload).length > 0) {
821832
ccrfiRelockPayload.push({ ...applicationIdPayload, ...unlockPayload });
822833
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<template>
2+
<v-card elevation="2" class="pa-4">
3+
<div class="mb-2">Please select one of the following options regarding the approvable fee schedule:</div>
4+
<v-radio-group v-model="updatedValue" :rules="rules.required" :disabled="readonly" color="primary">
5+
<v-radio label="I accept" :value="AFS_STATUSES.ACCEPT" />
6+
<div v-if="updatedValue === AFS_STATUSES.ACCEPT" class="text-body-2 pl-2">
7+
After submission please wait to receive notification confirming your approval to participate in CCFRI.
8+
</div>
9+
<v-radio label="I want to upload supporting documents" :value="AFS_STATUSES.UPLOAD_DOCUMENTS" />
10+
<v-radio label="I decline" :value="AFS_STATUSES.DECLINE" />
11+
<div v-if="updatedValue === AFS_STATUSES.DECLINE" class="text-body-2 pl-2">
12+
After submission please wait to receive confirmation from the ministry on the results of your CCFRI application.
13+
</div>
14+
</v-radio-group>
15+
</v-card>
16+
</template>
17+
18+
<script>
19+
import { AFS_STATUSES } from '@/utils/constants.js';
20+
import rules from '@/utils/rules.js';
21+
22+
export default {
23+
name: 'AfsDecisionCard',
24+
props: {
25+
readonly: {
26+
type: Boolean,
27+
default: false,
28+
},
29+
modelValue: {
30+
type: Number,
31+
default: null,
32+
},
33+
},
34+
emits: ['update:modelValue'],
35+
data() {
36+
return {
37+
updatedValue: null,
38+
};
39+
},
40+
watch: {
41+
modelValue: {
42+
handler(value) {
43+
this.updatedValue = value;
44+
},
45+
},
46+
updatedValue: {
47+
handler(value) {
48+
this.$emit('update:modelValue', value);
49+
},
50+
},
51+
},
52+
created() {
53+
this.updatedValue = this.modelValue;
54+
this.AFS_STATUSES = AFS_STATUSES;
55+
this.rules = rules;
56+
},
57+
};
58+
</script>
59+
<style scoped>
60+
:deep(.v-label) {
61+
opacity: 1;
62+
}
63+
</style>

frontend/src/components/ccfriApplication/AFS/ApprovableFeeSchedule.vue

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -67,29 +67,13 @@
6767
</div>
6868
<v-skeleton-loader :loading="isEmpty(afs)" type="table-tbody">
6969
<v-container fluid class="pa-0">
70-
<v-card elevation="2" class="pa-4">
71-
<div class="mb-2">
72-
Please select one of the following options regarding the approvable fee schedule:
73-
</div>
74-
<v-radio-group v-model="afs.afsStatus" :rules="rules.required" :disabled="isReadOnly" color="primary">
75-
<v-radio label="I accept" :value="AFS_STATUSES.ACCEPT" />
76-
<div v-if="afs?.afsStatus === AFS_STATUSES.ACCEPT" class="text-body-2 pl-2">
77-
After submission please wait to receive notification confirming your approval to participate in
78-
CCFRI.
79-
</div>
80-
<v-radio label="I want to upload supporting documents" :value="AFS_STATUSES.UPLOAD_DOCUMENTS" />
81-
<v-radio label="I decline" :value="AFS_STATUSES.DECLINE" />
82-
<div v-if="afs?.afsStatus === AFS_STATUSES.DECLINE" class="text-body-2 pl-2">
83-
After submission please wait to receive confirmation from the ministry on the results of your CCFRI
84-
application.
85-
</div>
86-
</v-radio-group>
87-
</v-card>
70+
<AfsDecisionCard v-model="afs.afsStatus" />
8871
<AppDocumentUpload
8972
v-if="afs?.afsStatus === AFS_STATUSES.UPLOAD_DOCUMENTS"
9073
:loading="isLoading"
9174
:uploaded-documents="filteredUploadedDocuments"
9275
:document-type="DOCUMENT_TYPES.APPLICATION_AFS"
76+
:show-error-message="showErrorMessage && !isSupportingDocumentsUploaded"
9377
title="Upload Supporting Documents (for example receipts, quotes, invoices and/or budget/finance documents here)."
9478
class="mt-8"
9579
@update-documents-to-upload="updateDocumentsToUpload"
@@ -118,6 +102,7 @@
118102
import { mapState, mapActions } from 'pinia';
119103
import { isEmpty, cloneDeep } from 'lodash';
120104
105+
import AfsDecisionCard from '@/components/ccfriApplication/AFS/AfsDecisionCard.vue';
121106
import ApprovableParentFeesCards from '@/components/ccfriApplication/AFS/ApprovableParentFeesCards.vue';
122107
import FacilityHeader from '@/components/guiComponents/FacilityHeader.vue';
123108
import AppDocumentUpload from '@/components/util/AppDocumentUpload.vue';
@@ -136,33 +121,20 @@ import rules from '@/utils/rules.js';
136121
137122
export default {
138123
name: 'ApprovableFeeSchedule',
139-
components: { AppDocumentUpload, ApprovableParentFeesCards, FacilityHeader, NavButton },
124+
components: { AppDocumentUpload, AfsDecisionCard, ApprovableParentFeesCards, FacilityHeader, NavButton },
140125
mixins: [alertMixin],
141126
async beforeRouteLeave(_to, _from, next) {
142127
await this.save(false);
143128
next();
144129
},
145-
props: {
146-
readonly: {
147-
type: Boolean,
148-
default: false,
149-
},
150-
ccfriApplicationId: {
151-
type: String,
152-
default: '',
153-
},
154-
facilityId: {
155-
type: String,
156-
default: '',
157-
},
158-
},
159130
data() {
160131
return {
161132
afs: {},
162133
documentsToUpload: [],
163134
uploadedDocumentsToDelete: [],
164135
isValidForm: false,
165136
processing: false,
137+
showErrorMessage: false,
166138
};
167139
},
168140
computed: {
@@ -177,9 +149,7 @@ export default {
177149
...mapState(useCcfriAppStore, ['approvableFeeSchedules']),
178150
...mapState(useNavBarStore, ['navBarList', 'nextPath', 'previousPath']),
179151
currentFacility() {
180-
return this.facilityId
181-
? this.navBarList?.find((el) => el.facilityId === this.facilityId)
182-
: this.navBarList?.find((el) => el.ccfriApplicationId === this.$route.params.urlGuid);
152+
return this.navBarList?.find((el) => el.ccfriApplicationId === this.$route.params.urlGuid);
183153
},
184154
filteredUploadedDocuments() {
185155
return this.applicationUploadedDocuments?.filter(
@@ -193,7 +163,7 @@ export default {
193163
},
194164
// Note: CCFRI-3752 - AFS for change request is not in scope at this time.
195165
isReadOnly() {
196-
return this.readonly || this.isLoading || (this.isApplicationSubmitted && !this.currentFacility?.unlockAfs);
166+
return this.isLoading || (this.isApplicationSubmitted && !this.currentFacility?.unlockAfs);
197167
},
198168
isSupportingDocumentsUploaded() {
199169
return this.filteredUploadedDocuments?.length + this.documentsToUpload?.length > 0;
@@ -214,6 +184,7 @@ export default {
214184
'$route.params.urlGuid': {
215185
handler() {
216186
this.reloadAfs();
187+
this.$refs.form?.validate();
217188
},
218189
},
219190
},
@@ -230,15 +201,14 @@ export default {
230201
...mapActions(useSupportingDocumentUploadStore, ['saveUploadedDocuments']),
231202
isEmpty,
232203
reloadAfs() {
233-
this.afs = this.ccfriApplicationId
234-
? this.approvableFeeSchedules?.find((item) => item.ccfriApplicationId === this.ccfriApplicationId)
235-
: this.approvableFeeSchedules?.find((item) => item.ccfriApplicationId === this.$route.params.urlGuid);
204+
this.afs = this.approvableFeeSchedules?.find((item) => item.ccfriApplicationId === this.$route.params.urlGuid);
236205
},
237206
next() {
238207
this.$router.push(this.nextPath);
239208
},
240209
validateForm() {
241210
this.$refs.form?.validate();
211+
this.showErrorMessage = true;
242212
},
243213
back() {
244214
this.$router.push(this.previousPath);
@@ -251,9 +221,11 @@ export default {
251221
const payload = {
252222
afsStatus: this.afs?.afsStatus,
253223
};
254-
await this.updateApplicationCCFRI(this.$route.params.urlGuid, payload);
255-
await this.processDocumentsToUpload();
256-
await DocumentService.deleteDocuments(this.uploadedDocumentsToDelete);
224+
await Promise.all([
225+
this.updateApplicationCCFRI(this.$route.params.urlGuid, payload),
226+
this.processDocumentsToUpload(),
227+
DocumentService.deleteDocuments(this.uploadedDocumentsToDelete),
228+
]);
257229
await this.getApplicationUploadedDocuments();
258230
this.setNavBarAfsComplete({ ccfriId: this.$route.params.urlGuid, complete: this.isFormComplete });
259231
if (showMessage) {

0 commit comments

Comments
 (0)