feat: melhorias no vínculo de tickets e exportação
This commit is contained in:
parent
1b32638eb5
commit
9495b54a28
7 changed files with 226 additions and 16 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { NextResponse } from "next/server"
|
||||
import { NextRequest, NextResponse } from "next/server"
|
||||
import type { Browser } from "playwright"
|
||||
|
||||
import { api } from "@/convex/_generated/api"
|
||||
|
|
@ -36,8 +36,12 @@ function buildDisposition(filename: string) {
|
|||
return `attachment; filename="${filename}"; filename*=UTF-8''${encoded}`
|
||||
}
|
||||
|
||||
export async function GET(request: Request, { params }: { params: { id: string; format: string } }) {
|
||||
const formatParam = params.format?.toLowerCase()
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
context: { params: Promise<{ id: string; format: string }> },
|
||||
) {
|
||||
const { id, format } = await context.params
|
||||
const formatParam = format?.toLowerCase()
|
||||
if (!isSupportedFormat(formatParam)) {
|
||||
return NextResponse.json({ error: "Formato não suportado" }, { status: 400 })
|
||||
}
|
||||
|
|
@ -74,10 +78,10 @@ export async function GET(request: Request, { params }: { params: { id: string;
|
|||
detail = await convex.query(api.dashboards.get, {
|
||||
tenantId,
|
||||
viewerId,
|
||||
dashboardId: params.id as Id<"dashboards">,
|
||||
dashboardId: id as Id<"dashboards">,
|
||||
})
|
||||
} catch (error) {
|
||||
console.error("[dashboards.export] Falha ao obter dashboard", error, { tenantId, dashboardId: params.id })
|
||||
console.error("[dashboards.export] Falha ao obter dashboard", error, { tenantId, dashboardId: id })
|
||||
return NextResponse.json({ error: "Não foi possível carregar o dashboard" }, { status: 500 })
|
||||
}
|
||||
|
||||
|
|
@ -85,8 +89,8 @@ export async function GET(request: Request, { params }: { params: { id: string;
|
|||
return NextResponse.json({ error: "Dashboard não encontrado" }, { status: 404 })
|
||||
}
|
||||
|
||||
const requestUrl = new URL(request.url)
|
||||
const printUrl = new URL(`/dashboards/${params.id}/print`, requestUrl.origin).toString()
|
||||
const requestUrl = request.nextUrl
|
||||
const printUrl = new URL(`/dashboards/${id}/print`, requestUrl.origin).toString()
|
||||
const waitForSelector = detail.dashboard.readySelector ?? WAIT_SELECTOR_DEFAULT
|
||||
const width = Number(requestUrl.searchParams.get("width") ?? DEFAULT_VIEWPORT_WIDTH) || DEFAULT_VIEWPORT_WIDTH
|
||||
const height = Number(requestUrl.searchParams.get("height") ?? DEFAULT_VIEWPORT_HEIGHT) || DEFAULT_VIEWPORT_HEIGHT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue