adjusted events view to only show the availability selector, when a user can do at least one task of the event

This commit is contained in:
z1glr
2025-02-07 11:28:14 +00:00
parent bc9deb5496
commit 353f51f2ae
8 changed files with 65 additions and 8 deletions

View File

@@ -144,8 +144,10 @@ export function validatePassword(password: string): string[] {
return errors;
}
export type TaskID = number;
export interface Task {
taskID: number | undefined;
taskID: TaskID | undefined;
taskName: string;
enabled: boolean;
}
@@ -219,3 +221,24 @@ export async function getUsers(): Promise<User[]> {
}
}
}
export async function getUserTasks(): Promise<TaskID[]> {
// check wether it is cached in zustand
const state = zustand.getState();
if (!!state.userTasks) {
return state.userTasks;
} else {
const result = await apiCall<TaskID[]>("GET", "user/tasks");
if (result.ok) {
const userTasks = await result.json();
state.patch({ userTasks });
return userTasks;
} else {
return [];
}
}
}