Closed #1 #2 #3 #4 #5 by converting all files to typescript. cant confirm everything working rn

This commit is contained in:
Jannis Heydemann
2026-04-29 15:04:52 +02:00
parent c88242b2be
commit 40ee49aff5
11 changed files with 149 additions and 2444 deletions

View File

@@ -51,14 +51,16 @@ function persistCurrentUser() {
}
}
let users = readStorageJson("eagleUsers", []);
export let users = readStorageJson("eagleUsers", []);
if (!Array.isArray(users)) {
users = [];
}
users = users.map(normalizeUser).filter(Boolean);
const rawCurrentUser = readStorageJson("currentUser", null);
var currentUser: User | null = rawCurrentUser ? normalizeUser(rawCurrentUser) : null;
export var currentUser: User | null = rawCurrentUser ? normalizeUser(rawCurrentUser) : null;
if (currentUser && currentUser.email) {
const currentEmail = currentUser.email;
const storedMatch = users.find((user: { email: string; }) => {
@@ -84,7 +86,7 @@ function getInputValue(id: string): string {
return el?.value.trim() ?? "";
}
async function registerUser() {
export async function registerUser() {
const firstName = getInputValue("reg-firstname");
const lastName = getInputValue("reg-lastname");
const email = getInputValue("reg-email").toLowerCase();
@@ -129,7 +131,7 @@ const password = document.querySelector<HTMLInputElement>("#reg-password")?.valu
openAccountDashboard();
}
async function loginUser() {
export async function loginUser() {
const email = (document.querySelector<HTMLInputElement>("#login-email")?.value.trim() || "").toLowerCase();
const password = document.querySelector<HTMLInputElement>("#login-password")?.value || "";
const hashedPassword = await hashMessage(password);
@@ -148,7 +150,7 @@ async function loginUser() {
openAccountDashboard();
}
function openAccountDashboard() {
export function openAccountDashboard() {
const accountView = document.getElementById("account-view");
if (!accountView) {
return;
@@ -464,3 +466,4 @@ function logoutUser() {
persistCurrentUser();
window.location.reload();
}