Skip to content

Commit

Permalink
Updates for removing school API.
Browse files Browse the repository at this point in the history
  • Loading branch information
arcshiftsolutions committed Oct 20, 2023
1 parent b33959f commit 3459b26
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 44 deletions.
4 changes: 2 additions & 2 deletions backend/src/routes/institute.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions frontend/src/common/apiService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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`),
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Check warning on line 413 in frontend/src/components/Home.vue

View workflow job for this annotation

GitHub Actions / test

The "computed" property should be above the "mounted" property on line 335

Check warning on line 413 in frontend/src/components/Home.vue

View workflow job for this annotation

GitHub Actions / test

The "computed" property should be above the "mounted" property on line 335
return REQUEST_TYPES;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/nominal-roll/MapSchoolCodeModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
density="compact"
name="1"
label="School District"
:items="schoolApiDistrictCodesObjectSorted"
:items="districtCodesObjectSorted"
:rules="[!validationErrors['School District'] || validationErrors['School District']]"
/>
</v-col>
Expand Down Expand Up @@ -252,7 +252,7 @@
density="compact"
name="3"
label="School Name"
:items="schoolApiMincodeSchoolNamesObjectSorted"
:items="mincodeSchoolNamesObjectSorted"
:rules="[!validationErrors['School Name'] || validationErrors['School Name']]"
/>
</v-col>
Expand Down Expand Up @@ -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']),
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export default {
},
computed: {
...mapState(penRequestBatchStore, ['selectedFiles', 'prbStudentStatusFilters', 'currentBatchFileSearchParams']),
...mapState(appStore, ['schoolApiMincodeSchoolNames']),
...mapState(appStore, ['mincodeSchoolNames']),
selectedSchoolGroup: {
get() {
return penRequestBatchStore().selectedSchoolGroup;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/mixins/schoolMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 5 additions & 19 deletions frontend/src/store/modules/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand All @@ -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){
Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
Expand Down

0 comments on commit 3459b26

Please sign in to comment.