diff --git a/backend/src/routes/institute.js b/backend/src/routes/institute.js index a0495cdf3..25aae081a 100644 --- a/backend/src/routes/institute.js +++ b/backend/src/routes/institute.js @@ -6,7 +6,7 @@ const { getDistricts, getSchools, getSchoolsPaginated, getAuthoritiesPaginated, addNewAuthorityNote, updateAuthorityNote, deleteAuthorityNote, updateSchool, addSchool, addSchoolContact, deleteSchoolContact, updateDistrict, updateDistrictContact, deleteDistrictContact, addAuthority, addDistrictContact, addNewDistrictNote, updateDistrictNote, deleteDistrictNote, moveSchool, getSchoolHistoryPaginated, getStudentRegistrationContacts, - getStudentRegistrationContactByMincode + getStudentRegistrationContactByMincode, getSchoolByMincode } = require('../components/institute/institute'); const utils = require('../components/utils'); const auth = require('../components/auth'); @@ -63,7 +63,7 @@ router.post('/school/contact', passport.authenticate('jwt', {session: false}, un router.get('/school/:id', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getSchoolByID); -router.get('/school/mincode/:id', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getSchoolByID); +router.get('/school/mincode/:mincode', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, getSchoolByMincode); router.put('/school/:id', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, updateSchool); diff --git a/frontend/src/common/apiService.js b/frontend/src/common/apiService.js index 8e86ce15e..70b1da2b8 100644 --- a/frontend/src/common/apiService.js +++ b/frontend/src/common/apiService.js @@ -82,7 +82,7 @@ export default { getPrbValidationFieldCodes: getCodes(Routes.penRequestBatch.PRB_VALIDATION_FIELD_CODE_URL), getPrbValidationIssueSeverityCodes: getCodes(Routes.penRequestBatch.PRB_VALIDATION_ISSUE_SEVERITY_CODE_URL), getPrbValidationIssueTypeCodes: getCodes(Routes.penRequestBatch.PRB_VALIDATION_ISSUE_TYPE_CODE_URL), - getMincodeSchoolNames: getCodes(Routes.cache.SCHOOL_DATA_URL), + getAllSchools: getCodes(Routes.cache.SCHOOL_DATA_URL), getActiveSchools: getCodes(`${Routes.cache.SCHOOL_DATA_URL}?active=true`), getActiveDistricts: getCodes(`${Routes.cache.DISTRICT_DATA_URL}?active=true`), getSchools:getCodes(Routes.cache.SCHOOL_DATA_URL), @@ -107,7 +107,6 @@ export default { getInstituteGradeCodes: getCodes(Routes.cache.GRADE_TYPES_URL), getInstituteProvinceCodes: getCodes(Routes.cache.PROVINCES_URL), getInstituteCountryCodes: getCodes(Routes.cache.COUNTRIES_URL), - getSchoolApiMincodeSchoolNames: getCodes(Routes.SCHOOL_DATA_URL), getSchoolCategoryFacilityTypes: getCodes(Routes.cache.SCHOOL_CATEGORY_FACILITY_TYPE_URL), getAllActiveFacilityTypeCodes: getCodes(`${Routes.cache.FACILITY_TYPES_URL}?active=true`), getAllActiveSchoolCategoryTypeCodes: getCodes(`${Routes.cache.SCHOOL_CATEGORY_TYPES_URL}?active=true`), diff --git a/frontend/src/components/Home.vue b/frontend/src/components/Home.vue index e71c649c8..2add190b7 100644 --- a/frontend/src/components/Home.vue +++ b/frontend/src/components/Home.vue @@ -408,7 +408,7 @@ export default { } }, computed: { - ...mapState(appStore, ['schoolApiMincodeSchoolNames', 'schoolApiDistrictCodes']), + ...mapState(appStore, ['mincodeSchoolNames', 'districtCodes']), ...mapState(authStore, ['VIEW_GMP_REQUESTS_ROLE', 'VIEW_UMP_REQUESTS_ROLE', 'ADVANCED_SEARCH_ROLE', 'VIEW_EDIT_PEN_REQUEST_BATCH_FILES_ROLE', 'HAS_STATS_ROLE', 'STUDENT_ANALYTICS_STUDENT_PROFILE', 'STUDENT_ANALYTICS_BATCH', 'EXCHANGE_ROLE', 'PEN_TEAM_ROLE']), requestTypes() { return REQUEST_TYPES; @@ -461,9 +461,9 @@ export default { isValidDistrictOrMincode(v) { if (isValidMincode(v) && (v.length === 3 || v.length === 8)) { if (v.length === 3) { - return this.schoolApiDistrictCodes.size === 0 || this.schoolApiDistrictCodes.has(v); + return this.districtCodes.size === 0 || this.districtCodes.has(v); } else { - return this.schoolApiMincodeSchoolNames.size === 0 || this.schoolApiMincodeSchoolNames.has(v); + return this.mincodeSchoolNames.size === 0 || this.mincodeSchoolNames.has(v); } } return false; diff --git a/frontend/src/components/nominal-roll/MapSchoolCodeModal.vue b/frontend/src/components/nominal-roll/MapSchoolCodeModal.vue index 535a72336..3777470e5 100644 --- a/frontend/src/components/nominal-roll/MapSchoolCodeModal.vue +++ b/frontend/src/components/nominal-roll/MapSchoolCodeModal.vue @@ -162,10 +162,10 @@ export default { }; }, computed: { - ...mapState(appStore, ['schoolApiMincodeSchoolNames']), + ...mapState(appStore, ['mincodeSchoolNames']), ...mapState(nominalRollStore, ['fedProvSchoolCodes']), schools() { - return _.sortBy(Array.from(this.schoolApiMincodeSchoolNames.entries()).map(school => ({ + return _.sortBy(Array.from(this.mincodeSchoolNames.entries()).map(school => ({ text: `${school[0]} - ${school[1]}`, value: school[0] })), ['value']); diff --git a/frontend/src/components/nominal-roll/NomRollStudentSearchResults.vue b/frontend/src/components/nominal-roll/NomRollStudentSearchResults.vue index 4b3081504..117760fec 100644 --- a/frontend/src/components/nominal-roll/NomRollStudentSearchResults.vue +++ b/frontend/src/components/nominal-roll/NomRollStudentSearchResults.vue @@ -205,7 +205,7 @@ density="compact" name="1" label="School District" - :items="schoolApiDistrictCodesObjectSorted" + :items="districtCodesObjectSorted" :rules="[!validationErrors['School District'] || validationErrors['School District']]" /> @@ -252,7 +252,7 @@ density="compact" name="3" label="School Name" - :items="schoolApiMincodeSchoolNamesObjectSorted" + :items="mincodeSchoolNamesObjectSorted" :rules="[!validationErrors['School Name'] || validationErrors['School Name']]" /> @@ -500,7 +500,7 @@ export default { computed: { ...mapState(nominalRollStudentSearchStore, ['nomRollStudentSearchResponse', 'nomRollStudentSearchCriteria', 'currentNomRollStudentSearchParams']), ...mapState(studentStore, ['genders', 'gradeCodeObjects']), - ...mapState(appStore, ['schoolApiMincodeSchoolNames', 'schoolApiDistrictCodes', 'schoolApiMincodeSchoolNamesObjectSorted', 'schoolApiDistrictCodesObjectSorted']), + ...mapState(appStore, ['mincodeSchoolNamesObjectSorted', 'districtCodesObjectSorted']), ...mapState(authStore, ['EDIT_NOMINAL_ROLL_ROLE', 'NOMINAL_ROLL_READ_ONLY_ROLE']), ...mapState(nominalRollStore, ['fedProvSchoolCodes']), ...mapState(notificationsStore, ['notification']), @@ -563,7 +563,7 @@ export default { return (format && column) ? format(column) : (column || ' '); }, getSchoolName(request) { - return appStore().schoolApiMincodeSchoolNames.get(request?.mincode?.replace(' ', '')); + return appStore().mincodeSchoolNames.get(request?.mincode?.replace(' ', '')); }, hasNoEditRoleAccess() { return this.EDIT_NOMINAL_ROLL_ROLE === false || this.hasReadOnlyRoleAccess(); diff --git a/frontend/src/components/penreg/penrequest-batch/PenRequestBatchDisplay.vue b/frontend/src/components/penreg/penrequest-batch/PenRequestBatchDisplay.vue index 116b2e927..0178dfef9 100644 --- a/frontend/src/components/penreg/penrequest-batch/PenRequestBatchDisplay.vue +++ b/frontend/src/components/penreg/penrequest-batch/PenRequestBatchDisplay.vue @@ -244,7 +244,7 @@ export default { }, computed: { ...mapState(penRequestBatchStore, ['selectedFiles', 'prbStudentStatusFilters', 'currentBatchFileSearchParams']), - ...mapState(appStore, ['schoolApiMincodeSchoolNames']), + ...mapState(appStore, ['mincodeSchoolNames']), selectedSchoolGroup: { get() { return penRequestBatchStore().selectedSchoolGroup; @@ -487,7 +487,7 @@ export default { formatArchivePayload(file) { return { penRequestBatchID: file.penRequestBatchID, - schoolName: this.schoolApiMincodeSchoolNames.get(file?.mincode?.replace(' ', '')) + schoolName: this.mincodeSchoolNames.get(file?.mincode?.replace(' ', '')) }; }, setSagaErrorMessage(error) { diff --git a/frontend/src/components/penreg/penrequest-batch/PrbStudentSearchResults.vue b/frontend/src/components/penreg/penrequest-batch/PrbStudentSearchResults.vue index 220be591d..2817dd3a0 100644 --- a/frontend/src/components/penreg/penrequest-batch/PrbStudentSearchResults.vue +++ b/frontend/src/components/penreg/penrequest-batch/PrbStudentSearchResults.vue @@ -306,7 +306,7 @@ export default { ...mapActions(penRequestBatchStudentSearchStore, ['setPageNumber', 'setSelectedRecords', 'setPrbStudentSearchResponse']), ...mapActions(navigationStore, ['setSelectedIDs', 'setArchived']), getSchoolName(request) { - return appStore().schoolApiMincodeSchoolNames.get(request?.mincode?.replace(' ','')); + return appStore().mincodeSchoolNames.get(request?.mincode?.replace(' ','')); }, clickViewSelected() { if(this.selectedRecords?.length > 0) { diff --git a/frontend/src/components/penreg/student/StudentAuditHistoryDetailCard.vue b/frontend/src/components/penreg/student/StudentAuditHistoryDetailCard.vue index 1fa94face..bb29f4eca 100644 --- a/frontend/src/components/penreg/student/StudentAuditHistoryDetailCard.vue +++ b/frontend/src/components/penreg/student/StudentAuditHistoryDetailCard.vue @@ -320,7 +320,7 @@ export default { return this.studentHistoryDetail.demogCode ? this.demogCodeObjects.filter(it => (it.demogCode === this.studentHistoryDetail.demogCode))[0].label : ''; }, getSchoolName(mincode) { - return appStore().schoolApiMincodeSchoolNames.get(mincode?.replace(' ', '')); + return appStore().mincodeSchoolNames.get(mincode?.replace(' ', '')); }, prefixFieldName(fieldName) { return this.idPrefix + fieldName.charAt(0).toUpperCase() + fieldName.slice(1); diff --git a/frontend/src/mixins/schoolMixin.js b/frontend/src/mixins/schoolMixin.js index bd6af0d77..b4a273fd1 100644 --- a/frontend/src/mixins/schoolMixin.js +++ b/frontend/src/mixins/schoolMixin.js @@ -17,8 +17,8 @@ export default { this.loadingSchoolData = true; try { const schoolData = await getSchoolData(mincode); - if (!!schoolData && !!schoolData.schoolName) { - this.schoolLabel = schoolData.schoolName; + if (!!schoolData && !!schoolData.displayName) { + this.schoolLabel = schoolData.displayName; this.mincodeError = false; this.mincodeErrors = []; } else { diff --git a/frontend/src/store/modules/app.js b/frontend/src/store/modules/app.js index 7b74dcde8..e33c40147 100644 --- a/frontend/src/store/modules/app.js +++ b/frontend/src/store/modules/app.js @@ -13,8 +13,6 @@ export const appStore = defineStore('app', { requestTypeLabel: REQUEST_TYPES.penRequest.label, pageTitle: null, stickyInfoPanelHeight: null, - schoolApiMincodeSchoolNames: new Map(), - schoolApiDistrictCodes: new Set(), mincodeSchoolNames: new Map(), schoolMap: new Map(), notClosedSchools: [], @@ -31,7 +29,9 @@ export const appStore = defineStore('app', { fundingGroups: [] }), getters: { - activeFundingGroups: state => state.fundingGroups.filter(group => group.expiryDate >= LocalDateTime.now().toString() && group.effectiveDate <= LocalDateTime.now().toString()) + activeFundingGroups: state => state.fundingGroups.filter(group => group.expiryDate >= LocalDateTime.now().toString() && group.effectiveDate <= LocalDateTime.now().toString()), + districtCodesObjectSorted: state => Array.from(state.districtCodes).sort(), + mincodeSchoolNamesObjectSorted: state => Object.values(Object.fromEntries(state.mincodeSchoolNames)).map(v => v.toUpperCase()).sort(), }, actions: { async setConfig(config){ @@ -105,13 +105,6 @@ export const appStore = defineStore('app', { this.alertNotification = true; } }, - async setSchoolApiMincodeSchoolNameAndDistrictCodes(schoolApiMincodeSchoolNameList) { - this.schoolApiMincodeSchoolNames = new Map(); - schoolApiMincodeSchoolNameList.forEach(element => { - this.schoolApiMincodeSchoolNames.set(element.mincode, element.schoolName); - this.schoolApiDistrictCodes.add(element.mincode?.substring(0, 3)); - }); - }, async setFundingGroups(fundingGroups) { this.fundingGroups = fundingGroups; this.fundingGroupsMap = new Map(); @@ -122,7 +115,7 @@ export const appStore = defineStore('app', { async getCodes() { if(localStorage.getItem('jwtToken')) { // DONT Call api if there is not token. if(this.mincodeSchoolNames.size === 0) { - const response = await ApiService.getMincodeSchoolNames(); + const response = await ApiService.getAllSchools(); await this.setMincodeSchoolNameAndDistrictCodes(response.data); } if (this.activeSchools.length === 0) { @@ -141,10 +134,6 @@ export const appStore = defineStore('app', { const response = await ApiService.getAuthorities(); await this.setIndependentAuthorities(response.data); } - if(this.schoolApiMincodeSchoolNames.size === 0) { - const response = await ApiService.getSchoolApiMincodeSchoolNames(); - await this.setSchoolApiMincodeSchoolNameAndDistrictCodes(response.data); - } if(this.fundingGroupsMap.size === 0 && !this.config.DISABLE_SDC_FUNCTIONALITY) { const response = await ApiService.getAllFundingGroups(); await this.setFundingGroups(response.data); @@ -157,7 +146,7 @@ export const appStore = defineStore('app', { }, async refreshEntities() { if(localStorage.getItem('jwtToken')) { // DONT Call api if there is not token. - const responseMinSchool = await ApiService.getMincodeSchoolNames(); + const responseMinSchool = await ApiService.getAllSchools(); await this.setMincodeSchoolNameAndDistrictCodes(responseMinSchool.data); const responseActiveSchools = await ApiService.getActiveSchools(); @@ -172,9 +161,6 @@ export const appStore = defineStore('app', { const response = await ApiService.getAuthorities(); await this.setIndependentAuthorities(response.data); - const responseSchoolApiMin = await ApiService.getSchoolApiMincodeSchoolNames(); - await this.setSchoolApiMincodeSchoolNameAndDistrictCodes(responseSchoolApiMin.data); - if(!this.config.DISABLE_SDC_FUNCTIONALITY) { const responseFunding = await ApiService.getAllFundingGroups(); await this.setFundingGroups(responseFunding.data); diff --git a/frontend/src/utils/common.js b/frontend/src/utils/common.js index 0b956759e..fcd501fea 100644 --- a/frontend/src/utils/common.js +++ b/frontend/src/utils/common.js @@ -198,15 +198,10 @@ export function updatePossibleMatchResultsBasedOnCurrentStatus(prbStudent, possi } export function getSchoolData(mincode) { - const params = { - params: { - mincode: mincode, - } - }; if (mincode) { return new Promise((resolve, reject) => { ApiService.apiAxios - .get(Routes.SCHOOL_DATA_URL, params) + .get(Routes.institute.SCHOOL_DATA_URL + '/mincode/' + mincode) .then(response => { resolve(response.data); })