Skip to content

Commit c8a9ffc

Browse files
Merge pull request #14 from Bunk-Mate/13-time-table-update-failure
fix: replace null with empty string before timetable patch and add gaurds for timetable load
2 parents 19ac0d6 + 8d9632d commit c8a9ffc

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

app/dashboard/(timetable)/edit/page.jsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export default function EditTable() {
5757
}, [popupDecision]);
5858

5959
const handleSaveTimetable = () => {
60+
const nullLessTableData = removeNull(tableData)
6061
addNotification('Request sent. Please wait.');
6162
const header = {
6263
Authorization:
@@ -65,7 +66,7 @@ export default function EditTable() {
6566
axios
6667
.patch(
6768
API_BASE_URL + '/collection',
68-
{ courses_data: tableData },
69+
{ courses_data: nullLessTableData },
6970
{ headers: header }
7071
)
7172
.then((response) => {
@@ -316,3 +317,15 @@ function getOptions({ timetable }) {
316317
}
317318
return options;
318319
}
320+
321+
function removeNull(tableData) {
322+
var nullLessTableData = tableData;
323+
for (let i = 0; i < tableData.length; i++) {
324+
for (let j = 0; j < 5; j++) {
325+
if (nullLessTableData[i][j] == null) {
326+
nullLessTableData[i][j] = '';
327+
}
328+
}
329+
}
330+
return nullLessTableData;
331+
}

components/shared_timetable/load_timetable.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ export default async function LoadTimetable({
1010
Authorization:
1111
'Token ' + JSON.parse(localStorage.getItem(ACCESS_TOKEN_NAME)),
1212
};
13+
if (selectedOption == undefined) {
14+
addNotification('Choose an option');
15+
return;
16+
}
1317
const payload = { copy_id: selectedOption.id };
1418
try {
1519
addNotification('Loading Timetable...');

0 commit comments

Comments
 (0)