diff --git a/WebApp/ts/eventList.ts b/WebApp/ts/eventList.ts index 5d0be4b..30e7884 100644 --- a/WebApp/ts/eventList.ts +++ b/WebApp/ts/eventList.ts @@ -81,17 +81,21 @@ async function loadEvents(org_id: number, evs?: Promise) { document.addEventListener("DOMContentLoaded", async () => { - var user = await getMyAccount(); var org_id: number = -1; - if (user) { - if (user.isOrganisation) { - unhideElementById(document, "mainContainer"); - unhideElementById(document, "addnewevent-btn"); - org_id = user.organisationId; + try { + var user = await getMyAccount(); + + if (user) { + if (user.isOrganisation) { + unhideElementById(document, "mainContainer"); + unhideElementById(document, "addnewevent-btn"); + org_id = user.organisationId; + } + unhideElementById(document, "logout-btn"); } - unhideElementById(document, "logout-btn"); - } else { + } catch { + // console.log("User not signed in. Failing gracefully."); unhideElementById(document, "joinnow-btn"); unhideElementById(document, "signin-btn"); } @@ -106,7 +110,7 @@ document.addEventListener("DOMContentLoaded", async () => { const searchBar = document.getElementById('searchbar') as HTMLInputElement; searchBar.addEventListener('keydown', (event) => { if (event.key === 'Enter') { - console.log('Enter key pressed!'); + // console.log('Enter key pressed!'); var searchResults = getEvents(searchBar.value); loadEvents(org_id, searchResults); } diff --git a/WebApp/ts/eventModify.ts b/WebApp/ts/eventModify.ts index aeb20b0..d39830f 100644 --- a/WebApp/ts/eventModify.ts +++ b/WebApp/ts/eventModify.ts @@ -53,13 +53,16 @@ async function modifyEvent() document.addEventListener("DOMContentLoaded", async () => { var container = document.getElementById("mainContainer"); const saveBtn = document.getElementById("saveBtn"); - var user = await getMyAccount(); - if (user) { - if (user.isOrganisation) { - unhideElementById(document, "mainContainer"); + + try { + var user = await getMyAccount(); + if (user) { + if (user.isOrganisation) { + unhideElementById(document, "mainContainer"); + } + unhideElementById(document, "logout-btn"); } - unhideElementById(document, "logout-btn"); - } else { + } catch { unhideElementById(document, "joinnow-btn"); unhideElementById(document, "signin-btn"); } diff --git a/WebApp/ts/eventView.ts b/WebApp/ts/eventView.ts index 4fd337d..c906b0f 100644 --- a/WebApp/ts/eventView.ts +++ b/WebApp/ts/eventView.ts @@ -6,18 +6,20 @@ const eventId = urlParams.get('event'); document.addEventListener("DOMContentLoaded", async () => { - var container = document.getElementById("mainContainer"); - var user = await getMyAccount(); - var org_id: number = -1; - const modifyBtn = document.getElementById( "editBtn"); + var container = document.getElementById("mainContainer"); + const modifyBtn = document.getElementById("editBtn"); const removeBtn = document.getElementById("removeBtn"); + var org_id: number = -1; - if (user) { - if (user.isOrganisation) { - org_id = user.organisationId; + try { + var user = await getMyAccount(); + if (user) { + if (user.isOrganisation) { + org_id = user.organisationId; + } + unhideElementById(document, "logout-btn"); } - unhideElementById(document, "logout-btn"); - } else { + } catch { unhideElementById(document, "joinnow-btn"); unhideElementById(document, "signin-btn"); } diff --git a/WebApp/wwwroot/js/eventList.js b/WebApp/wwwroot/js/eventList.js index 342cbce..c2fc172 100644 --- a/WebApp/wwwroot/js/eventList.js +++ b/WebApp/wwwroot/js/eventList.js @@ -85,17 +85,20 @@ function loadEvents(org_id, evs) { }); } document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, void 0, function* () { - var user = yield getMyAccount(); var org_id = -1; - if (user) { - if (user.isOrganisation) { - unhideElementById(document, "mainContainer"); - unhideElementById(document, "addnewevent-btn"); - org_id = user.organisationId; + try { + var user = yield getMyAccount(); + if (user) { + if (user.isOrganisation) { + unhideElementById(document, "mainContainer"); + unhideElementById(document, "addnewevent-btn"); + org_id = user.organisationId; + } + unhideElementById(document, "logout-btn"); } - unhideElementById(document, "logout-btn"); } - else { + catch (_a) { + // console.log("User not signed in. Failing gracefully."); unhideElementById(document, "joinnow-btn"); unhideElementById(document, "signin-btn"); } @@ -109,7 +112,7 @@ document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, vo const searchBar = document.getElementById('searchbar'); searchBar.addEventListener('keydown', (event) => { if (event.key === 'Enter') { - console.log('Enter key pressed!'); + // console.log('Enter key pressed!'); var searchResults = getEvents(searchBar.value); loadEvents(org_id, searchResults); } diff --git a/WebApp/wwwroot/js/eventModify.js b/WebApp/wwwroot/js/eventModify.js index 5ec5c85..df42c99 100644 --- a/WebApp/wwwroot/js/eventModify.js +++ b/WebApp/wwwroot/js/eventModify.js @@ -52,14 +52,16 @@ function modifyEvent() { document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, void 0, function* () { var container = document.getElementById("mainContainer"); const saveBtn = document.getElementById("saveBtn"); - var user = yield getMyAccount(); - if (user) { - if (user.isOrganisation) { - unhideElementById(document, "mainContainer"); + try { + var user = yield getMyAccount(); + if (user) { + if (user.isOrganisation) { + unhideElementById(document, "mainContainer"); + } + unhideElementById(document, "logout-btn"); } - unhideElementById(document, "logout-btn"); } - else { + catch (_a) { unhideElementById(document, "joinnow-btn"); unhideElementById(document, "signin-btn"); } diff --git a/WebApp/wwwroot/js/eventView.js b/WebApp/wwwroot/js/eventView.js index 05e98ca..c150877 100644 --- a/WebApp/wwwroot/js/eventView.js +++ b/WebApp/wwwroot/js/eventView.js @@ -13,17 +13,19 @@ const urlParams = new URLSearchParams(queryString); const eventId = urlParams.get('event'); document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, void 0, function* () { var container = document.getElementById("mainContainer"); - var user = yield getMyAccount(); - var org_id = -1; const modifyBtn = document.getElementById("editBtn"); const removeBtn = document.getElementById("removeBtn"); - if (user) { - if (user.isOrganisation) { - org_id = user.organisationId; + var org_id = -1; + try { + var user = yield getMyAccount(); + if (user) { + if (user.isOrganisation) { + org_id = user.organisationId; + } + unhideElementById(document, "logout-btn"); } - unhideElementById(document, "logout-btn"); } - else { + catch (_a) { unhideElementById(document, "joinnow-btn"); unhideElementById(document, "signin-btn"); }