fix(types): avoid Prisma CompanyUpdateInput strict typing due to out-of-sync generated types; use generic updates map and cast at call site
This commit is contained in:
parent
b4bc01bc7e
commit
2272c2a10e
1 changed files with 2 additions and 3 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
import { NextResponse } from "next/server"
|
import { NextResponse } from "next/server"
|
||||||
|
|
||||||
import { prisma } from "@/lib/prisma"
|
import { prisma } from "@/lib/prisma"
|
||||||
import type { Prisma } from "@prisma/client"
|
|
||||||
import { assertAdminSession } from "@/lib/auth-server"
|
import { assertAdminSession } from "@/lib/auth-server"
|
||||||
|
|
||||||
export const runtime = "nodejs"
|
export const runtime = "nodejs"
|
||||||
|
|
@ -22,7 +21,7 @@ export async function PATCH(request: Request, { params }: { params: Promise<{ id
|
||||||
contractedHoursPerMonth: number | string | null
|
contractedHoursPerMonth: number | string | null
|
||||||
}>
|
}>
|
||||||
|
|
||||||
const updates: Prisma.CompanyUpdateInput = {}
|
const updates: Record<string, unknown> = {}
|
||||||
if (typeof raw.name === "string" && raw.name.trim()) updates.name = raw.name.trim()
|
if (typeof raw.name === "string" && raw.name.trim()) updates.name = raw.name.trim()
|
||||||
if (typeof raw.slug === "string" && raw.slug.trim()) updates.slug = raw.slug.trim()
|
if (typeof raw.slug === "string" && raw.slug.trim()) updates.slug = raw.slug.trim()
|
||||||
if ("cnpj" in raw) updates.cnpj = raw.cnpj ?? null
|
if ("cnpj" in raw) updates.cnpj = raw.cnpj ?? null
|
||||||
|
|
@ -37,7 +36,7 @@ export async function PATCH(request: Request, { params }: { params: Promise<{ id
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const company = await prisma.company.update({ where: { id }, data: updates })
|
const company = await prisma.company.update({ where: { id }, data: updates as any })
|
||||||
return NextResponse.json({ company })
|
return NextResponse.json({ company })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to update company", error)
|
console.error("Failed to update company", error)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue