fix: front-end improvements

makes some fields visible and other hidden depending on the result of
some API calls, e.g. visitor is logged in -> show "Log out" button
This commit is contained in:
2025-05-19 00:43:15 +02:00
parent e0e6fa0573
commit 5536a9ad7f
15 changed files with 465 additions and 22 deletions

View File

@@ -0,0 +1,38 @@
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) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
export function unhideElementById(document, e) {
return __awaiter(this, void 0, void 0, function* () {
var element = document.getElementById(e);
if (element) {
element.classList.remove('hidden-before-load');
console.log(element.classList);
}
});
}
export function getEvent(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield fetch("/api/events/" + id);
if (!res.ok) {
throw Error("To wydarzenie nie istnieje");
}
const events = yield res.json();
return events;
});
}
export function getMyAccount() {
return __awaiter(this, void 0, void 0, function* () {
const res = yield fetch("/api/auth/my_account");
if (!res.ok) {
throw Error("Użytkownik niezalogowany!");
}
const data = yield res.json();
return data;
});
}