diff --git a/WebApp/ts/calendar.ts b/WebApp/ts/calendar.ts index 9960864..eafbb6b 100644 --- a/WebApp/ts/calendar.ts +++ b/WebApp/ts/calendar.ts @@ -1,3 +1,6 @@ +import { unhideElementById, getMyAccount } from './generalUseHelpers.js'; + + async function getRegisteredEvents(): Promise { const res = await fetch("/api/events/registered"); if (!res.ok) throw new Error("Couldn't load joined events"); @@ -12,6 +15,17 @@ async function getRegisteredEvents(): Promise { document.addEventListener("DOMContentLoaded", async () => { + + try { + var user = await getMyAccount(); + if (user) { + unhideElementById(document, "logout-btn"); + } + } catch { + unhideElementById(document, "joinnow-btn"); + unhideElementById(document, "signin-btn"); + } + const calendarEl = document.getElementById("calendar") as HTMLElement; if (!calendarEl) return; diff --git a/WebApp/wwwroot/calendar.html b/WebApp/wwwroot/calendar.html index f767150..179c3b2 100644 --- a/WebApp/wwwroot/calendar.html +++ b/WebApp/wwwroot/calendar.html @@ -73,5 +73,6 @@ + diff --git a/WebApp/wwwroot/js/calendar.js b/WebApp/wwwroot/js/calendar.js index d9c1045..681fec0 100644 --- a/WebApp/wwwroot/js/calendar.js +++ b/WebApp/wwwroot/js/calendar.js @@ -1,4 +1,3 @@ -"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -8,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; +import { unhideElementById, getMyAccount } from './generalUseHelpers.js'; function getRegisteredEvents() { return __awaiter(this, void 0, void 0, function* () { const res = yield fetch("/api/events/registered"); @@ -22,6 +22,16 @@ function getRegisteredEvents() { }); } document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, void 0, function* () { + try { + var user = yield getMyAccount(); + if (user) { + unhideElementById(document, "logout-btn"); + } + } + catch (_a) { + unhideElementById(document, "joinnow-btn"); + unhideElementById(document, "signin-btn"); + } const calendarEl = document.getElementById("calendar"); if (!calendarEl) return;