Skip to content

Commit

Permalink
Merge pull request #179 from bcgov/funding-agreement-fix
Browse files Browse the repository at this point in the history
added call for funding agreements for account mgmt screens
  • Loading branch information
jenbeckett authored Apr 25, 2024
2 parents 252af02 + 21b2844 commit 3f9e34c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions frontend/src/services/applicationService.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { isEmpty } from 'lodash'

import ApiService from '@/common/apiService'
import FundingAgreementService from '@/services/fundingAgreementService'
import { useApplicationsStore } from '@/stores/applications'
import { useAuthStore } from '@/stores/auth'
import { ApiRoutes } from '@/utils/constants'
Expand Down Expand Up @@ -168,16 +169,16 @@ export default {

checkFundingAgreement(fundingAgreement) {
const isUnexpired = new Date() < new Date(fundingAgreement?.endDate)

return fundingAgreement?.stateCode === CRM_STATE_CODES.ACTIVE && isUnexpired
},

async hasActiveApplicationOrFundingAgreement(facilities = []) {
const results = await Promise.all(
facilities.map(async (facility) => {
const applications = await this.getApplicationsByFacilityId(facility.facilityId)
return applications?.some((application) => {
return this.checkApplicationStatus(application) || this.checkFundingAgreement(application?.fundingAgreements)
return applications?.some(async (application) => {
application.fundingAgreement = await FundingAgreementService.getActiveFundingAgreementByApplicationId(application.applicationId)
return this.checkApplicationStatus(application) || this.checkFundingAgreement(application?.fundingAgreement)
})
}),
)
Expand Down

0 comments on commit 3f9e34c

Please sign in to comment.