Skip to content

Commit

Permalink
updated the district list to sort by active and district number
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunlumbcgov committed Jan 15, 2025
1 parent 863da4c commit 3f53490
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions frontend/src/sharedMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,25 @@ export default {
jobLabel(jobId) {
return this.jobId.replace("job-", "");
},
sortDistrictListByActiveAndDistrictNumber(districtsList) {
if (!districtsList) return [];

return districtsList.sort((a, b) => {
// First, prioritize districts with districtStatusCode "ACTIVE"
if (a.districtStatusCode === "ACTIVE" && b.districtStatusCode !== "ACTIVE") {
return -1; // "ACTIVE" comes first
}
if (a.districtStatusCode !== "ACTIVE" && b.districtStatusCode === "ACTIVE") {
return 1; // "ACTIVE" comes first
}

// Second, sort by districtNumber (as numeric, handling strings like "103", "005", etc.)
const aNumber = parseInt(a.districtNumber, 10);
const bNumber = parseInt(b.districtNumber, 10);

return aNumber - bNumber; // Numeric sorting
});
},
sortSchoolListByTranscriptsAndMincode(schoolsList) {
if (!schoolsList) return [];
//remove special characters from displayname by overwriting with displayNameNoSpecialChars
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/store/modules/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export const useAppStore = defineStore("app", {
InstituteService.getDistrictsList().then((response) => {
try {
this.districtsList = response.data;
this.districtList =
sharedMethods.sortDistrictListByActiveAndDistrictNumber(
this.districtsList
);
} catch (error) {
console.error(error);
}
Expand Down

0 comments on commit 3f53490

Please sign in to comment.