fix(studentInfo): some cases year may be undefined

This commit is contained in:
SethBurkart123
2024-11-29 10:29:35 +11:00
parent 00c9f03827
commit 34306e77cf
+11 -3
View File
@@ -13,7 +13,11 @@ export async function AddBetterSEQTAElements() {
document.documentElement.classList.add('dark'); document.documentElement.classList.add('dark');
} }
createHomeButton(); createHomeButton();
await appendBackgroundToUI(); try {
await appendBackgroundToUI();
} catch (error) {
console.error('Error appending background to UI:', error);
}
await handleUserInfo(); await handleUserInfo();
handleStudentData(); handleStudentData();
createNewsButton(); createNewsButton();
@@ -144,7 +148,7 @@ async function getUserInfo() {
} }
async function updateStudentInfo(students: any) { async function updateStudentInfo(students: any) {
const info = await getUserInfo(); // You would need to implement this to fetch or pass the user info const info = await getUserInfo();
var index = students.findIndex(function (person: any) { var index = students.findIndex(function (person: any) {
return ( return (
person.firstname == info.userDesc.split(' ')[0] && person.firstname == info.userDesc.split(' ')[0] &&
@@ -167,7 +171,11 @@ async function updateStudentInfo(students: any) {
} }
} }
} else { } else {
houseelement.innerText = students[index].year; try {
houseelement.innerText = students[index].year;
} catch(err) {
houseelement.innerText = 'N/A';
}
} }
} }