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:
Esdras Renan 2025-10-09 23:00:51 -03:00
parent b4bc01bc7e
commit 2272c2a10e

View file

@ -1,7 +1,6 @@
import { NextResponse } from "next/server"
import { prisma } from "@/lib/prisma"
import type { Prisma } from "@prisma/client"
import { assertAdminSession } from "@/lib/auth-server"
export const runtime = "nodejs"
@ -22,7 +21,7 @@ export async function PATCH(request: Request, { params }: { params: Promise<{ id
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.slug === "string" && raw.slug.trim()) updates.slug = raw.slug.trim()
if ("cnpj" in raw) updates.cnpj = raw.cnpj ?? null
@ -37,7 +36,7 @@ export async function PATCH(request: Request, { params }: { params: Promise<{ id
}
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 })
} catch (error) {
console.error("Failed to update company", error)