Skip to content

Commit

Permalink
Merge pull request #440 from bcgov/ofmcc-6780-2
Browse files Browse the repository at this point in the history
Add cancelled and ineligble applications to application history view
  • Loading branch information
SoLetsDev authored Jan 14, 2025
2 parents a8dc0a8 + f4352c8 commit 1dd087b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 9 deletions.
30 changes: 30 additions & 0 deletions frontend/src/services/applicationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ function sortApplications(applications) {
}

export default {
async getApplicationsByFacilityId(facilityId) {
try {
if (!facilityId) return
const response = await ApiService.apiAxios.get(`${ApiRoutes.APPLICATIONS}?facilityId=${facilityId}`)
return response?.data
} catch (error) {
console.log(`Failed to get the list of applications by facility id - ${error}`)
throw error
}
},

async getActiveApplicationsByFacilityId(facilityId) {
try {
if (!facilityId) return
Expand Down Expand Up @@ -52,6 +63,25 @@ export default {
}
},

async getApplications() {
try {
const authStore = useAuthStore()
const facilities = authStore?.userInfo?.facilities
let applications = []
await Promise.all(
facilities?.map(async (facility) => {
const response = await this.getApplicationsByFacilityId(facility.facilityId)
applications = applications?.concat(response)
}),
)
sortApplications(applications)
return applications
} catch (error) {
console.log(`Failed to get the applications - ${error}`)
throw error
}
},

async getActiveApplications() {
try {
const authStore = useAuthStore()
Expand Down
34 changes: 25 additions & 9 deletions frontend/src/views/applications/ApplicationsHistoryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
class="soft-outline"
density="compact">
<template #item.status="{ item }">
<span :class="getStatusClass(item.statusCode)">{{ item.status }}</span>
<span :class="getStatusClass(item.statusCode)">{{ getStatusLabel(item) }}</span>
</template>

<template #item.actions="{ item }">
Expand Down Expand Up @@ -222,8 +222,11 @@ export default {
return this.applications?.some((application) => ApplicationService.isValidApplication(application)) && this.hasGoodStanding
},
filteredApplicationItems() {
const hiddenCodes = [APPLICATION_STATUS_CODES.EXPIRED, APPLICATION_STATUS_CODES.REDIRECTED]
return this.sortApplicationItems(
this.applicationItems.filter((application) => !this.facilityNameFilter || application.facilityName?.toLowerCase().includes(this.facilityNameFilter.toLowerCase())),
this.applicationItems
.filter((application) => !this.facilityNameFilter || application.facilityName?.toLowerCase().includes(this.facilityNameFilter.toLowerCase()))
.filter((application) => !hiddenCodes.includes(application.statusCode)),
)
},
ofmApplicationCardText() {
Expand Down Expand Up @@ -301,7 +304,9 @@ export default {
},
showPDFDownloadButton(application) {
if (application.applicationType === APPLICATION_TYPES.IRREGULAR_EXPENSE || application.statusCode === APPLICATION_STATUS_CODES.REDIRECTED) {
const invalidAppCodes = [APPLICATION_STATUS_CODES.INELIGIBLE, APPLICATION_STATUS_CODES.CANCELLED_BY_MINISTRY, APPLICATION_STATUS_CODES.CANCELLED_BY_SP]
if (application.applicationType === APPLICATION_TYPES.IRREGULAR_EXPENSE || invalidAppCodes.includes(application.statusCode)) {
return false
//OFM core generates PDF upon submit - Supp App generates PDF only once approved
} else if (application.applicationType === APPLICATION_TYPES.OFM) {
Expand Down Expand Up @@ -336,15 +341,18 @@ export default {
},
async getApplicationsAndFundingAgreement() {
this.applications = await ApplicationService.getActiveApplications()
// Applications' funding agreements are used in applications validation to enable the Add Supplementary Application button
let applications = await ApplicationService.getApplications()
// Applications' funding agreements are used in applications validation to enable the Add SupplementaryApplication
// Application button
await Promise.all(
this.applications?.map(async (application) => {
applications.map(async (application) => {
application.status = application.statusCode === APPLICATION_STATUS_CODES.VERIFIED ? 'In Review' : application.status
//we should ignore MOD igreements below - if MOD FA is in status of not active - it will prevent the user from applying for Irreg Expense funding
// we should ignore MOD igreements below - if MOD FA is in status of not active - it will prevent the user
// from applying for Irreg Expense funding
application.fundingAgreement = await FundingAgreementService.getActiveFundingAgreementByApplicationId(application.applicationId, true)
}),
)
this.applications = applications
},
async getSupplementaryApplications() {
Expand Down Expand Up @@ -422,9 +430,17 @@ export default {
const supplementaryApplicationItems = this.transformSupplementaryApplicationsToItems(this.supplementaryApplications, applicationItemsMap)
this.applicationItems = [...this.applicationItems, ...supplementaryApplicationItems, ...this.irregularExpenses]
},
getStatusLabel(applicationItem) {
if ([APPLICATION_STATUS_CODES.CANCELLED_BY_SP, APPLICATION_STATUS_CODES.CANCELLED_BY_MINISTRY].includes(applicationItem.statusCode)) {
return 'Cancelled'
}
return applicationItem.status
},
getStatusClass(statusCode) {
if (this.DRAFT_STATUS_CODES.includes(statusCode) || statusCode === APPLICATION_STATUS_CODES.REDIRECTED) {
if (
this.DRAFT_STATUS_CODES.includes(statusCode) ||
[APPLICATION_STATUS_CODES.REDIRECTED, APPLICATION_STATUS_CODES.INELIGIBLE, APPLICATION_STATUS_CODES.CANCELLED_BY_MINISTRY, APPLICATION_STATUS_CODES.CANCELLED_BY_SP].includes(statusCode)
) {
return 'status-gray'
} else if (
[
Expand Down

0 comments on commit 1dd087b

Please sign in to comment.