Fixes: 1. useFetch: add credentials:'same-origin' — cookie wasn't being sent with API calls, causing 401 → React error boundary → 'Etwas ist schiefgelaufen' 2. Instance detail Sheet now loads correctly (cookie sent with request) New instance actions (UI + API): - Redeploy: triggers Dokploy application.redeploy (rebuilds from latest commit) - Stop: triggers Dokploy application.stop (pauses container) - Start: triggers Dokploy application.start (resumes container) - Remove: existing delete (SlideCommit confirmation) Dokploy deploy fix: - deployApplication now calls markRunning before deploy - This ensures Dokploy creates a deployment job ActionsRow redesigned: - demo_active/active: [Redeploy] [Stop] [Demo +7d] [Remove] - grace: [Start] [Remove] - failed: [Retry] [Remove] - provisioning/deleting/deleted: no actions
46 lines
1.5 KiB
TypeScript
Executable File
46 lines
1.5 KiB
TypeScript
Executable File
import { NextResponse } from 'next/server'
|
|
import { db } from '@/lib/db'
|
|
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
// PATCH /api/aos/tickets/[id]/escalate
|
|
// An agency escalates a ticket to us (the platform admin). After escalation,
|
|
// the ticket appears in our admin inbox (scope=admin sees escalated tickets).
|
|
export async function PATCH(_req: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
try {
|
|
const { id } = await params
|
|
const ticket = await db.ticket.findUnique({ where: { id } })
|
|
if (!ticket) {
|
|
return NextResponse.json({ error: 'ticket not found' }, { status: 404 })
|
|
}
|
|
if (ticket.escalatedToAdmin) {
|
|
return NextResponse.json({ error: 'already escalated' }, { status: 409 })
|
|
}
|
|
|
|
await db.ticket.update({
|
|
where: { id },
|
|
data: {
|
|
escalatedToAdmin: true,
|
|
escalatedAt: new Date(),
|
|
status: 'open', // reopen for admin attention
|
|
},
|
|
})
|
|
|
|
await db.auditLog.create({
|
|
data: {
|
|
actor: 'agency:escalate',
|
|
action: 'ticket.escalate',
|
|
entity: 'Ticket',
|
|
entityId: id,
|
|
after: JSON.stringify({ number: ticket.number, escalatedAt: new Date() }),
|
|
hash: 'sha256:' + Math.random().toString(36).slice(2),
|
|
},
|
|
})
|
|
|
|
return NextResponse.json({ ok: true, escalatedToAdmin: true })
|
|
} catch (err) {
|
|
const msg = err instanceof Error ? err.message : 'internal server error'
|
|
return NextResponse.json({ error: msg }, { status: 500 })
|
|
}
|
|
}
|