Convert multiple pages into SPA

This commit is contained in:
2025-10-09 15:48:23 +02:00
parent c616b2da7f
commit 06d04a1abc
110 changed files with 1245 additions and 1319 deletions

View File

@@ -106,14 +106,18 @@ export type UserSession = {
valid_domains: string[],
}
export const get_user = async () => {
let cached_user: User = null
export const get_user = async (): Promise<User> => {
if ((window as any).user !== undefined) {
return (window as any).user as User
} else if (cached_user !== null) {
return cached_user
}
console.warn("user property is not defined on window")
return await check_response(await fetch(get_endpoint() + "/user")) as User
cached_user = await check_response(await fetch(get_endpoint() + "/user")) as User
return cached_user
}
export const put_user = async (data: Object) => {
@@ -128,7 +132,6 @@ export const put_user = async (data: Object) => {
}
}
export type VATRate = {
name: string,
vat: number,