feat: make the apply button redirect logged out users to login.html

This commit is contained in:
2025-06-02 01:36:52 +02:00
parent b075ef7e78
commit 4a82822d64
2 changed files with 13 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ import { getEvent, getMyAccount, unhideElementById, getMyRegisteredEventIds } fr
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const eventId = urlParams.get('event');
var redirected = false;
document.addEventListener("DOMContentLoaded", async () => {
@@ -71,7 +72,10 @@ document.addEventListener("DOMContentLoaded", async () => {
} catch {
unhideElementById(document, "applyBtn");
(applyBtn as HTMLButtonElement).textContent = "log in to apply";
(applyBtn as HTMLButtonElement).disabled = true;
(applyBtn as HTMLButtonElement).addEventListener("click", async (e) => {
redirected = true;
window.location.href = "login.html";
});
}
}
@@ -112,6 +116,7 @@ document.addEventListener("DOMContentLoaded", async () => {
if (applyBtn) {
applyBtn.addEventListener("click", async (e) => {
if (redirected) return;
try {
const response = await fetch(`/api/events/join/${eventId}`, {
method: "POST",

View File

@@ -11,6 +11,7 @@ import { getEvent, getMyAccount, unhideElementById, getMyRegisteredEventIds } fr
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const eventId = urlParams.get('event');
var redirected = false;
document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, void 0, function* () {
var container = document.getElementById("mainContainer");
const modifyBtn = document.getElementById("editBtn");
@@ -78,7 +79,10 @@ document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, vo
catch (_b) {
unhideElementById(document, "applyBtn");
applyBtn.textContent = "log in to apply";
applyBtn.disabled = true;
applyBtn.addEventListener("click", (e) => __awaiter(void 0, void 0, void 0, function* () {
redirected = true;
window.location.href = "login.html";
}));
}
}
unhideElementById(document, "mainContainer");
@@ -115,6 +119,8 @@ document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, vo
if (applyBtn) {
applyBtn.addEventListener("click", (e) => __awaiter(void 0, void 0, void 0, function* () {
var _c;
if (redirected)
return;
try {
const response = yield fetch(`/api/events/join/${eventId}`, {
method: "POST",