unit(D8): optimistic grid editor + toast (assign/clear reverts on failure)

This commit is contained in:
Tiel Coder
2026-11-18 18:44:22 +00:00
parent 71b993e663
commit 137a135a5e
5 changed files with 242 additions and 6 deletions
+26
View File
@@ -0,0 +1,26 @@
import { eq, sql } from "drizzle-orm";
import { users } from "@/db/schema";
/**
* Active users (id + display name) for the assign picker (unit D8).
*
* D8's assign control lists every active user; skill gating (rules 6/13) and
* ranking live on the picker in D6/D9/D10, not here. `display_name` falls back
* to first + last so a user with no display name still reads sensibly.
*/
const userName = sql<string>`coalesce(${users.displayName}, ${users.firstName} || ' ' || ${users.lastName})`;
export interface VolunteerOption {
id: string;
displayName: string;
}
export async function activeVolunteers(
db: typeof import("@/db").db,
): Promise<VolunteerOption[]> {
return db
.select({ id: users.id, displayName: userName })
.from(users)
.where(eq(users.status, "active"))
.orderBy(users.lastName, users.firstName);
}