Skip to content

Commit

Permalink
Optimized user requests batch so that it does not call Graduation rep…
Browse files Browse the repository at this point in the history
…ort api for each onCreate
  • Loading branch information
KentoHyono committed Jan 15, 2025
1 parent 3f53490 commit 4922725
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 40 deletions.
77 changes: 41 additions & 36 deletions frontend/src/components/Batch/Forms/DistrunUserForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ import DistributionInput from "@/components/Batch/Forms/FormInputs/DistributionI
import { mapActions, mapState } from "pinia";
import BatchProcessingService from "@/services/BatchProcessingService.js";
import { useAppStore } from "../../../store/modules/app";
import { useAccessStore } from "../../../store/modules/access";
import { useAuthStore } from "../../../store/modules/auth";
import { useSnackbarStore } from "../../../store/modules/snackbar";
Expand Down Expand Up @@ -536,42 +537,46 @@ export default {
"setActiveTab",
"updateDashboards",
]),
getTranscriptTypes() {
GraduationReportService.getTranscriptTypes()
.then((response) => {
this.transcriptTypes = response.data;
})
// eslint-disable-next-line
.catch((error) => {
if (error.response.statusText) {
console.log("ERROR " + error.response.statusText, "danger");
} else {
console.log("ERROR " + "error with webservice", "danger");
}
});
},
getCertificateTypes() {
GraduationReportService.getCertificateTypes()
.then((response) => {
this.certificateTypes = response.data;
})
// eslint-disable-next-line
.catch((error) => {
if (error.response.statusText) {
this.snackbarStore.showSnackbar(
"ERROR " + error.response.statusText,
"danger",
10000
);
} else {
this.snackbarStore.showSnackbar(
"ERROR " + "error with web service",
"danger",
10000
);
}
});
},
...mapState(useAppStore, [
"getTranscriptTypes",
"getCertificateTypes"
]),
// getTranscriptTypes() {
// GraduationReportService.getTranscriptTypes()
// .then((response) => {
// this.transcriptTypes = response.data;
// })
// // eslint-disable-next-line
// .catch((error) => {
// if (error.response.statusText) {
// console.log("ERROR " + error.response.statusText, "danger");
// } else {
// console.log("ERROR " + "error with webservice", "danger");
// }
// });
// },
// getCertificateTypes() {
// GraduationReportService.getCertificateTypes()
// .then((response) => {
// this.certificateTypes = response.data;
// })
// // eslint-disable-next-line
// .catch((error) => {
// if (error.response.statusText) {
// this.snackbarStore.showSnackbar(
// "ERROR " + error.response.statusText,
// "danger",
// 10000
// );
// } else {
// this.snackbarStore.showSnackbar(
// "ERROR " + "error with web service",
// "danger",
// 10000
// );
// }
// });
// },
closeDialogAndResetForm() {
this.blankCertificateDetails = [];
this.blankTranscriptDetails = [];
Expand Down
41 changes: 37 additions & 4 deletions frontend/src/store/modules/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineStore } from "pinia";
import ApiService from "../../common/apiService.js";
import InstituteService from "../../services/InstituteService.js";
import GraduationReportService from "@/services/GraduationReportService.js";
import sharedMethods from "../../sharedMethods.js";
export const useAppStore = defineStore("app", {
state: () => ({
Expand All @@ -10,6 +11,8 @@ export const useAppStore = defineStore("app", {
pageTitle: "GRAD",
districtsList: [],
schoolsList: [],
transcriptTypes: [],
certificationTypes: []
}),
getters: {
getProgramOptions: (state) => state.programOptions,
Expand Down Expand Up @@ -55,6 +58,8 @@ export const useAppStore = defineStore("app", {
(gradeCode) => code === gradeCode.schoolGradeCode
);
},
getTranscriptTypes: (state) => state.transcriptTypes,
getCertificateTypes: (state) => state.certificationTypes
},
actions: {
setApplicationVariables() {
Expand Down Expand Up @@ -100,10 +105,6 @@ 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 Expand Up @@ -149,6 +150,38 @@ export const useAppStore = defineStore("app", {
console.error(error);
}
});
GraduationReportService.getTranscriptTypes().then((response) => {
try {
this.transcriptTypes = response.data;
console.log("Transcript Service")
} catch (error) {
if (error.response.statusText) {
console.log("ERROR " + error.response.statusText, "danger");
} else {
console.log("ERROR " + "error with webservice", "danger");
}
}
})
GraduationReportService.getCertificateTypes().then((response) => {
try {
this.certificationTypes = response.data;
console.log("Certificate Service")
} catch (error) {
if (error.response.statusText) {
this.snackbarStore.showSnackbar(
"ERROR " + error.response.statusText,
"danger",
10000
);
} else {
this.snackbarStore.showSnackbar(
"ERROR " + "error with web service",
"danger",
10000
);
}
}
})
}
},
},
Expand Down

0 comments on commit 4922725

Please sign in to comment.