diff --git a/frontend/src/services/applicationService.js b/frontend/src/services/applicationService.js index 0b384a3b..10b1402f 100644 --- a/frontend/src/services/applicationService.js +++ b/frontend/src/services/applicationService.js @@ -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 @@ -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() diff --git a/frontend/src/views/applications/ApplicationsHistoryView.vue b/frontend/src/views/applications/ApplicationsHistoryView.vue index 24178f16..bb2ecde8 100644 --- a/frontend/src/views/applications/ApplicationsHistoryView.vue +++ b/frontend/src/views/applications/ApplicationsHistoryView.vue @@ -82,7 +82,7 @@ class="soft-outline" density="compact">