unit(D8): optimistic grid editor + toast (assign/clear reverts on failure)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user