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:
@@ -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 [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user