feat: CSV exports, PDF improvements, play internal/external with hour split, roles cleanup, admin companies with 'Cliente avulso', ticket list spacing/alignment fixes, status translations and mappings
This commit is contained in:
parent
addd4ce6e8
commit
3bafcc5a0a
45 changed files with 1401 additions and 256 deletions
27
src/app/api/admin/companies/[id]/route.ts
Normal file
27
src/app/api/admin/companies/[id]/route.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { NextResponse } from "next/server"
|
||||
|
||||
import { prisma } from "@/lib/prisma"
|
||||
import { assertAdminSession } from "@/lib/auth-server"
|
||||
|
||||
export const runtime = "nodejs"
|
||||
|
||||
export async function PATCH(request: Request, { params }: { params: Promise<{ id: string }> }) {
|
||||
const session = await assertAdminSession()
|
||||
if (!session) return NextResponse.json({ error: "Não autorizado" }, { status: 401 })
|
||||
const { id } = await params
|
||||
const body = await request.json()
|
||||
|
||||
const updates: Record<string, any> = {}
|
||||
for (const key of ["name", "slug", "cnpj", "domain", "phone", "description", "address"]) {
|
||||
if (key in body) updates[key] = body[key] ?? null
|
||||
}
|
||||
if ("isAvulso" in body) updates.isAvulso = Boolean(body.isAvulso)
|
||||
|
||||
try {
|
||||
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)
|
||||
return NextResponse.json({ error: "Falha ao atualizar empresa" }, { status: 500 })
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue