Rollen Chunk 6: Team-Tab mit Matrix-Kalender und Genehmigungen
Docker Image / test (push) Successful in 1m51s
Docker Image / image (push) Successful in 33s

This commit is contained in:
loki committed 2026-10-11 20:19:09 +02:00
1 parent 89ebd49c1c
commit ce5368de4a
1 file changed
+42
+42
View File
@@ -80,6 +80,48 @@ export function userExists(db: Db, userId: string): boolean {
return row !== undefined;
}
export interface TeamUser {
id: string;
name: string;
email: string;
role: UserRole;
}
export function listAllUsers(db: Db): TeamUser[] {
const rows = db
.prepare(
'SELECT id, name, email, role FROM "user" WHERE banned IS NOT 1 ORDER BY createdAt',
)
.all() as { id: string; name: string; email: string; role: string | null }[];
return rows.map((row) => ({
id: row.id,
name: row.name,
email: row.email,
role:
row.role === "admin" || row.role === "teamleiter"
? row.role
: "benutzer",
}));
}
export function setVacationStatus(
db: Db,
userId: string,
id: number,
status: VacationStatus,
): boolean {
// Nur offene Anfragen entscheiden; bestätigte gehen über den Papierkorb.
if (status !== "bestätigt" && status !== "abgelehnt") {
return false;
}
const result = db
.prepare(
"UPDATE vacation_requests SET status = ? WHERE id = ? AND user_id = ? AND status = 'beantragt' AND deleted_at IS NULL",
)
.run(status, id, userId);
return result.changes > 0;
}
export type UserRole = "admin" | "teamleiter" | "benutzer";
export function getUserRole(db: Db, userId: string): UserRole {