Skip to content

Commit 5649c7c

Browse files
committed
ccfri-3752 - update after code review
1 parent f8ea1cb commit 5649c7c

File tree

2 files changed

+23
-40
lines changed

2 files changed

+23
-40
lines changed

frontend/src/components/LandingPage.vue

+17-33
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@
335335
</v-container>
336336
</template>
337337
<script>
338-
import _ from 'lodash';
338+
import { isEmpty } from 'lodash';
339339
import { mapState, mapActions } from 'pinia';
340340
import { useAuthStore } from '@/store/auth.js';
341341
import { useAppStore } from '@/store/app.js';
@@ -545,39 +545,23 @@ export default {
545545
this.unlockEcewe ||
546546
this.unlockLicenseUpload ||
547547
this.unlockSupportingDocuments ||
548-
this.unlockCCFRIList.length > 0 ||
549-
this.unlockNMFList.length > 0 ||
550-
this.unlockRFIList.length > 0 ||
551-
this.unlockAFSList.length > 0
548+
!isEmpty(this.unlockCCFRIList) ||
549+
!isEmpty(this.unlockNMFList) ||
550+
!isEmpty(this.unlockRFIList) ||
551+
!isEmpty(this.unlockAFSList)
552552
);
553553
},
554554
unlockCCFRIList() {
555-
let unlockList = [];
556-
this.navBarList?.forEach((facility) => {
557-
if (facility.unlockCcfri) unlockList.push(facility.ccfriApplicationId);
558-
});
559-
return unlockList;
555+
return this.getUnlockCCFRIList(this.navBarList);
560556
},
561557
unlockNMFList() {
562-
let unlockList = [];
563-
this.navBarList?.forEach((facility) => {
564-
if (facility.unlockNmf) unlockList.push(facility.ccfriApplicationId);
565-
});
566-
return unlockList;
558+
return this.getUnlockNMFList(this.navBarList);
567559
},
568560
unlockRFIList() {
569-
let unlockList = [];
570-
this.navBarList?.forEach((facility) => {
571-
if (facility.unlockRfi) unlockList.push(facility.ccfriApplicationId);
572-
});
573-
return unlockList;
561+
return this.getUnlockRFIList(this.navBarList);
574562
},
575563
unlockAFSList() {
576-
const unlockList = [];
577-
this.navBarList?.forEach((facility) => {
578-
if (facility.unlockAfs && facility.enableAfs) unlockList.push(facility.ccfriApplicationId);
579-
});
580-
return unlockList;
564+
return this.getUnlockAFSList(this.navBarList);
581565
},
582566
isCCOFApproved() {
583567
return this.applicationType === 'RENEW' || this.ccofStatus === this.CCOF_STATUS_APPROVED;
@@ -764,10 +748,10 @@ export default {
764748
this.goToCCOFFunding(programYearId, facilityList);
765749
else if (application?.unlockEcewe) this.goToECEWE(programYearId);
766750
else if (application?.unlockSupportingDocuments) this.goToSupportingDocumentUpload(programYearId);
767-
else if (unlockCCFRIList?.length > 0) this.goToCCFRI(unlockCCFRIList[0], application);
768-
else if (unlockNMFList?.length > 0) this.goToNMF(unlockNMFList[0], programYearId);
769-
else if (unlockRFIList?.length > 0) this.goToRFI(unlockRFIList[0], programYearId);
770-
else if (unlockAFSList?.length > 0) this.goToAFS(unlockAFSList[0], programYearId);
751+
else if (!isEmpty(unlockCCFRIList)) this.goToCCFRI(unlockCCFRIList[0], application);
752+
else if (!isEmpty(unlockNMFList)) this.goToNMF(unlockNMFList[0], programYearId);
753+
else if (!isEmpty(unlockRFIList)) this.goToRFI(unlockRFIList[0], programYearId);
754+
else if (!isEmpty(unlockAFSList)) this.goToAFS(unlockAFSList[0], programYearId);
771755
else if (application?.unlockDeclaration) this.goToSummaryDeclaration(programYearId);
772756
},
773757
actionRequiredFacilityRoute(ccfriApplicationId) {
@@ -816,28 +800,28 @@ export default {
816800
return application?.applicationStatus === 'SUBMITTED' && unlockAFSList?.includes(ccfriApplicationId);
817801
},
818802
getUnlockCCFRIList(facilityList) {
819-
let unlockList = [];
803+
const unlockList = [];
820804
facilityList?.forEach((facility) => {
821805
if (facility.unlockCcfri) unlockList.push(facility.ccfriApplicationId);
822806
});
823807
return unlockList;
824808
},
825809
getUnlockNMFList(facilityList) {
826-
let unlockList = [];
810+
const unlockList = [];
827811
facilityList?.forEach((facility) => {
828812
if (facility.unlockNmf) unlockList.push(facility.ccfriApplicationId);
829813
});
830814
return unlockList;
831815
},
832816
getUnlockRFIList(facilityList) {
833-
let unlockList = [];
817+
const unlockList = [];
834818
facilityList?.forEach((facility) => {
835819
if (facility.unlockRfi) unlockList.push(facility.ccfriApplicationId);
836820
});
837821
return unlockList;
838822
},
839823
getUnlockAFSList(facilityList) {
840-
let unlockList = [];
824+
const unlockList = [];
841825
facilityList?.forEach((facility) => {
842826
if (facility.unlockAfs && facility.enableAfs) unlockList.push(facility.ccfriApplicationId);
843827
});

frontend/src/utils/common.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,12 @@ export function filterFacilityListForPCF(facilityList, isRenewal, applicationSta
8888

8989
export function checkApplicationUnlocked(application) {
9090
const facilityList = application?.facilityList;
91-
const isCCFRIUnlocked =
92-
facilityList?.findIndex((facility) => isFacilityAvailable(facility) && facility.unlockCcfri) > -1;
93-
const isNMFUnlocked = facilityList?.findIndex((facility) => isFacilityAvailable(facility) && facility.unlockNmf) > -1;
94-
const isRFIUnlocked = facilityList?.findIndex((facility) => isFacilityAvailable(facility) && facility.unlockRfi) > -1;
95-
const isAFSUnlocked =
96-
facilityList?.findIndex((facility) => isFacilityAvailable(facility) && facility.unlockAfs && facility.enableAfs) >
97-
-1;
91+
const isCCFRIUnlocked = facilityList?.some((facility) => isFacilityAvailable(facility) && facility.unlockCcfri);
92+
const isNMFUnlocked = facilityList?.some((facility) => isFacilityAvailable(facility) && facility.unlockNmf);
93+
const isRFIUnlocked = facilityList?.some((facility) => isFacilityAvailable(facility) && facility.unlockRfi);
94+
const isAFSUnlocked = facilityList?.some(
95+
(facility) => isFacilityAvailable(facility) && facility.unlockAfs && facility.enableAfs,
96+
);
9897
const isApplicationUnlocked =
9998
(application?.unlockBaseFunding && application?.applicationType === 'NEW') ||
10099
application?.unlockLicenseUpload ||

0 commit comments

Comments
 (0)