Fix GPU inventory typing and user role mapping
This commit is contained in:
parent
42611df0f5
commit
4f812a2e4c
3 changed files with 183 additions and 84 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { NextResponse } from "next/server"
|
||||
import { api } from "@/convex/_generated/api"
|
||||
import type { Id } from "@/convex/_generated/dataModel"
|
||||
import type { UserRole } from "@prisma/client"
|
||||
import { api } from "@/convex/_generated/api"
|
||||
import { ConvexHttpClient } from "convex/browser"
|
||||
import { prisma } from "@/lib/prisma"
|
||||
import { DEFAULT_TENANT_ID } from "@/lib/constants"
|
||||
|
|
@ -12,12 +13,11 @@ function normalizeRole(input: string | null | undefined): RoleOption {
|
|||
return ((ROLE_OPTIONS as readonly string[]).includes(candidate) ? candidate : "agent") as RoleOption
|
||||
}
|
||||
|
||||
function mapToUserRole(role: RoleOption) {
|
||||
const value = role.toUpperCase()
|
||||
if (["ADMIN", "MANAGER", "AGENT", "COLLABORATOR"].includes(value)) {
|
||||
return value
|
||||
}
|
||||
return "AGENT"
|
||||
const USER_ROLE_OPTIONS: ReadonlyArray<UserRole> = ["ADMIN", "MANAGER", "AGENT", "COLLABORATOR"]
|
||||
|
||||
function mapToUserRole(role: RoleOption): UserRole {
|
||||
const candidate = role.toUpperCase() as UserRole
|
||||
return USER_ROLE_OPTIONS.includes(candidate) ? candidate : "AGENT"
|
||||
}
|
||||
|
||||
export const runtime = "nodejs"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue