mirror of
https://github.com/GCMatters/hermes.git
synced 2026-02-04 05:30:13 +01:00
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
43 lines
1010 B
TypeScript
43 lines
1010 B
TypeScript
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;
|
|
}
|
|
|