mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 05:30: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:
42
WebApp/ts/generalUseHelpers.ts
Normal file
42
WebApp/ts/generalUseHelpers.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
interface EventData {
|
||||
title: string;
|
||||
location: string;
|
||||
description: string;
|
||||
eventDate: string;
|
||||
}
|
||||
|
||||
interface MyAccount {
|
||||
userId: number;
|
||||
email: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
createdAt: string;
|
||||
isOrganisation: boolean;
|
||||
}
|
||||
|
||||
export async function unhideElementById(document: Document, e: string) {
|
||||
var element = document.getElementById(e);
|
||||
if (element) {
|
||||
element.classList.remove('hidden-before-load');
|
||||
console.log(element.classList);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getEvent(id: string): Promise<EventData> {
|
||||
const res = await fetch("/api/events/" + id);
|
||||
if (!res.ok) {
|
||||
throw Error("To wydarzenie nie istnieje");
|
||||
}
|
||||
const events = await res.json();
|
||||
return events;
|
||||
}
|
||||
|
||||
export async function getMyAccount(): Promise<MyAccount> {
|
||||
const res = await fetch("/api/auth/my_account");
|
||||
if (!res.ok) {
|
||||
throw Error("U¿ytkownik niezalogowany!");
|
||||
}
|
||||
const data = await res.json();
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user