Files
hermes/WebApp/wwwroot/js/generalUseHelpers.js
eee4 5536a9ad7f 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
2025-05-19 00:43:15 +02:00

39 lines
1.6 KiB
JavaScript

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;
});
}