fix: align report schedule route context types
This commit is contained in:
parent
127e117ea9
commit
d859c1196c
1 changed files with 9 additions and 5 deletions
|
|
@ -12,14 +12,17 @@ import {
|
|||
|
||||
export const runtime = "nodejs"
|
||||
|
||||
export async function PATCH(request: Request, { params }: { params: { id: string } }) {
|
||||
type RouteContext = { params: Promise<{ id: string }> }
|
||||
|
||||
export async function PATCH(request: Request, context: RouteContext) {
|
||||
const { id } = await context.params
|
||||
const session = await assertAdminSession()
|
||||
if (!session) {
|
||||
return NextResponse.json({ error: "Não autorizado" }, { status: 401 })
|
||||
}
|
||||
const tenantId = session.user.tenantId ?? DEFAULT_TENANT_ID
|
||||
const schedule = await prisma.reportExportSchedule.findFirst({
|
||||
where: { id: params.id, tenantId },
|
||||
where: { id, tenantId },
|
||||
})
|
||||
if (!schedule) {
|
||||
return NextResponse.json({ error: "Agendamento não encontrado" }, { status: 404 })
|
||||
|
|
@ -140,14 +143,15 @@ export async function PATCH(request: Request, { params }: { params: { id: string
|
|||
})
|
||||
}
|
||||
|
||||
export async function DELETE(_: Request, { params }: { params: { id: string } }) {
|
||||
export async function DELETE(_: Request, context: RouteContext) {
|
||||
const { id } = await context.params
|
||||
const session = await assertAdminSession()
|
||||
if (!session) {
|
||||
return NextResponse.json({ error: "Não autorizado" }, { status: 401 })
|
||||
}
|
||||
const tenantId = session.user.tenantId ?? DEFAULT_TENANT_ID
|
||||
await prisma.reportExportRun.deleteMany({ where: { scheduleId: params.id, tenantId } })
|
||||
await prisma.reportExportSchedule.deleteMany({ where: { id: params.id, tenantId } })
|
||||
await prisma.reportExportRun.deleteMany({ where: { scheduleId: id, tenantId } })
|
||||
await prisma.reportExportSchedule.deleteMany({ where: { id, tenantId } })
|
||||
return NextResponse.json({ success: true })
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue