Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added institute codes to app store on application load #710

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading