admin/companies: melhorar criação/edição\n\n- Aceita isAvulso e contractedHoursPerMonth no POST\n- Retorna 409 para duplicidade (slug/provisioningCode)\n- Retorna 409 para duplicidade no PATCH
This commit is contained in:
parent
e6e343fe38
commit
f60a48e7b3
2 changed files with 22 additions and 2 deletions
|
|
@ -48,6 +48,9 @@ export async function PATCH(request: Request, { params }: { params: Promise<{ id
|
|||
return NextResponse.json({ company })
|
||||
} catch (error) {
|
||||
console.error("Failed to update company", error)
|
||||
if (error instanceof Prisma.PrismaClientKnownRequestError && error.code === "P2002") {
|
||||
return NextResponse.json({ error: "Já existe uma empresa com este slug." }, { status: 409 })
|
||||
}
|
||||
return NextResponse.json({ error: "Falha ao atualizar empresa" }, { status: 500 })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue