Skip to content
Snippets Groups Projects
Commit 80e20f8e authored by Ihsan M. A.'s avatar Ihsan M. A. 🇯🇵
Browse files

Hotfix/update study plan courses

parent 64e10670
1 merge request!51Hotfix/update study plan courses
...@@ -77,8 +77,8 @@ const updateStudyPlan = async (studyPlan, changeset) => { ...@@ -77,8 +77,8 @@ const updateStudyPlan = async (studyPlan, changeset) => {
const { studyPlanCourses } = changeset; const { studyPlanCourses } = changeset;
if (studyPlanCourses) { if (studyPlanCourses) {
deleteAllStudyPlanCourses(studyPlan.id); await deleteAllStudyPlanCourses(studyPlan.id);
recreateAllStudyPlanCourses(studyPlan.id, studyPlanCourses); await recreateAllStudyPlanCourses(studyPlan.id, studyPlanCourses);
} }
const result = await studyPlan.update(changeset); const result = await studyPlan.update(changeset);
...@@ -97,18 +97,12 @@ const deleteAllStudyPlanCourses = async (studyPlanId) => { ...@@ -97,18 +97,12 @@ const deleteAllStudyPlanCourses = async (studyPlanId) => {
}; };
const recreateAllStudyPlanCourses = async (studyPlanId, studyPlanCourses) => { const recreateAllStudyPlanCourses = async (studyPlanId, studyPlanCourses) => {
await studyPlanCourses.forEach(async (course) => { for (const course of studyPlanCourses) {
const {
courseClassId,
status
} = course;
await StudyPlanCourse.create({ await StudyPlanCourse.create({
studyPlanId, studyPlanId,
courseClassId, ...course,
status
}); });
}); }
}; };
module.exports = { module.exports = {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment