sync-docs-and-fixes
This commit is contained in:
@@ -4,7 +4,7 @@ import { cache } from "react"
|
||||
import { asc, eq, inArray, or } from "drizzle-orm"
|
||||
|
||||
import { db } from "@/shared/db"
|
||||
import { academicYears, departments, grades, schools, users } from "@/shared/db/schema"
|
||||
import { academicYears, departments, grades, roles, schools, users, usersToRoles } from "@/shared/db/schema"
|
||||
import type { AcademicYearListItem, DepartmentListItem, GradeListItem, SchoolListItem, StaffOption } from "./types"
|
||||
|
||||
const toIso = (d: Date) => d.toISOString()
|
||||
@@ -114,7 +114,10 @@ export const getStaffOptions = cache(async (): Promise<StaffOption[]> => {
|
||||
const rows = await db
|
||||
.select({ id: users.id, name: users.name, email: users.email })
|
||||
.from(users)
|
||||
.where(inArray(users.role, ["teacher", "admin"]))
|
||||
.innerJoin(usersToRoles, eq(usersToRoles.userId, users.id))
|
||||
.innerJoin(roles, eq(usersToRoles.roleId, roles.id))
|
||||
.where(inArray(roles.name, ["teacher", "admin"]))
|
||||
.groupBy(users.id, users.name, users.email)
|
||||
.orderBy(asc(users.name), asc(users.email))
|
||||
|
||||
return rows.map((r) => ({
|
||||
|
||||
Reference in New Issue
Block a user