mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 13:40:13 +01:00
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:
38
WebApp/wwwroot/js/generalUseHelpers.js
Normal file
38
WebApp/wwwroot/js/generalUseHelpers.js
Normal 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;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user