fix: filter selected courses

在手機端使用時,「預覽排課」的功能會導致未經點選+號的「預覽課程」被選入

經儲存於資料庫後會導致學分數計算錯誤。

solution: 在前端先篩選出正確的課程再送給後端API儲存
This commit is contained in:
Ting-Jun Wang 2022-08-30 20:53:55 +08:00
parent f8d2147fc9
commit 17e6e1421e
Signed by: snsd0805
GPG Key ID: 8DB0D22BC1217D33

View File

@ -114,6 +114,12 @@ var mainWindow = {
'saveCourseTable': function () { 'saveCourseTable': function () {
var main = this var main = this
if (this.token != "") { if (this.token != "") {
filteredCourses = []
for(var tempCourse of main.selectCourses){
if(tempCourse.temp == false){
filteredCourses.push(tempCourse);
}
}
fetch('https://api.snsd0805.com/courseTable', { fetch('https://api.snsd0805.com/courseTable', {
method: 'POST', method: 'POST',
headers: { headers: {
@ -121,7 +127,7 @@ var mainWindow = {
}, },
body: JSON.stringify({ body: JSON.stringify({
'token': main.token, 'token': main.token,
'data': main.selectCourses 'data': filteredCourses
}) })
}) })
.then(function (response) { .then(function (response) {