Skip to content

Commit

Permalink
feat: include cancelled & ineligible apps in hist.
Browse files Browse the repository at this point in the history
  • Loading branch information
trev-dev committed Jan 11, 2025
1 parent a8dc0a8 commit bcf17d9
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 11 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
62 changes: 51 additions & 11 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,15 @@ 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 +308,16 @@ 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 +352,22 @@ 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) => {
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
application.fundingAgreement = await FundingAgreementService.getActiveFundingAgreementByApplicationId(application.applicationId, true)
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
application.fundingAgreement = await FundingAgreementService.getActiveFundingAgreementByApplicationId(
application.applicationId,
true,
)
}),
)
this.applications = applications
},
async getSupplementaryApplications() {
Expand Down Expand Up @@ -422,9 +445,26 @@ 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 bcf17d9

Please sign in to comment.