Skip to content

Commit

Permalink
Merge pull request #710 from bcgov/GRAD2-2751-Sam
Browse files Browse the repository at this point in the history
Added institute codes to app store on application load
  • Loading branch information
michaeltangbcgov authored Jan 10, 2025
2 parents effb65b + d69140e commit 69fca6f
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
14 changes: 14 additions & 0 deletions frontend/src/services/InstituteService.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,18 @@ export default {
getDistrictById(id) {
return ApiService.apiAxios.get("/api/v1/institute/district/" + id);
},

// GET Institute Codes
getAddressTypeCodes() {
return ApiService.apiAxios.get("/api/v1/institute/address-type-codes");
},
getSchoolCategoryCodes() {
return ApiService.apiAxios.get("/api/v1/institute/category-codes");
},
getFacilityCodes() {
return ApiService.apiAxios.get("/api/v1/institute/facility-codes");
},
getGradeCodes() {
return ApiService.apiAxios.get("/api/v1/institute/grade-codes");
},
};
60 changes: 60 additions & 0 deletions frontend/src/store/modules/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,34 @@ export const useAppStore = defineStore("app", {
(district) => districtId === district.districtId
);
},
getInstituteAddressTypeCodes: (state) => state.instituteAddressTypeCodes,
getInstituteAddressTypeCode: (state) => {
return (code) =>
state.instituteAddressTypeCodes.find(
(addressTypeCode) => code === addressTypeCode.addressTypeCode
);
},
getInstituteCategoryCodes: (state) => state.instituteCategoryCodes,
getInstituteCategoryByCode: (state) => {
return (code) =>
state.instituteCategoryCodes.find(
(categoryCode) => code === categoryCode.schoolCategoryCode
);
},
getInstituteFacilityCodes: (state) => state.instituteFacilityCodes,
getInstituteFacilityCode: (state) => {
return (code) =>
state.instituteFacilityCodes.find(
(facilityCode) => code === facilityCode.facilityTypeCode
);
},
getInstituteGradeCodes: (state) => state.instituteGradeCodes,
getInstituteGradeCode: (state) => {
return (code) =>
state.instituteGradeCodes.find(
(gradeCode) => code === gradeCode.schoolGradeCode
);
},
},
actions: {
setApplicationVariables() {
Expand Down Expand Up @@ -67,6 +95,8 @@ export const useAppStore = defineStore("app", {
console.log(error);
}
});

// SET INSTITUTE SCHOOL AND DISTRICT DATA
InstituteService.getDistrictsList().then((response) => {
try {
this.districtsList = response.data;
Expand All @@ -85,6 +115,36 @@ export const useAppStore = defineStore("app", {
console.error(error);
}
});

// SET INSTITUTE CODES
InstituteService.getAddressTypeCodes().then((response) => {
try {
this.instituteAddressTypeCodes = response.data;
} catch (error) {
console.error(error);
}
});
InstituteService.getCategoryCodes().then((response) => {
try {
this.instituteCategoryCodes = response.data;
} catch (error) {
console.error(error);
}
});
InstituteService.getFacilityCodes().then((response) => {
try {
this.instituteFacilityCodes = response.data;
} catch (error) {
console.error(error);
}
});
InstituteService.getGradeCodes().then((response) => {
try {
this.instituteGradeCodes = response.data;
} catch (error) {
console.error(error);
}
});
}
},
},
Expand Down

0 comments on commit 69fca6f

Please sign in to comment.