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 10, 2025
1 parent 0ed99c4 commit 80ad7cf
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 12 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 @@ -57,6 +68,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
50 changes: 38 additions & 12 deletions frontend/src/views/applications/ApplicationsHistoryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,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 @@ -238,7 +238,6 @@ export default {
facilityNameFilter: undefined,
applicationTypeToCancel: undefined,
showChangeRequestDialog: false,
hiddenApplicationStatusCodes: [APPLICATION_STATUS_CODES.EXPIRED, APPLICATION_STATUS_CODES.REDIRECTED],
}
},
Expand Down Expand Up @@ -268,12 +267,15 @@ export default {
)
},
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 @@ -359,9 +361,15 @@ export default {
},
showPDFDownloadButton(application) {
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 ||
application.statusCode === APPLICATION_STATUS_CODES.REDIRECTED
invalidAppCodes.includes(application.statusCode)
) {
return false
//OFM core generates PDF upon submit - Supp App generates PDF only once approved
Expand Down Expand Up @@ -405,11 +413,11 @@ export default {
},
async getApplicationsAndFundingAgreement() {
this.applications = await ApplicationService.getActiveApplications()
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
Expand All @@ -420,6 +428,7 @@ export default {
)
}),
)
this.applications = applications
},
async getSupplementaryApplications() {
Expand Down Expand Up @@ -509,9 +518,26 @@ export default {
)
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 80ad7cf

Please sign in to comment.