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
43 lines
1.3 KiB
TypeScript
Executable File
43 lines
1.3 KiB
TypeScript
Executable File
import { NextResponse } from 'next/server'
|
|
import { db } from '@/lib/db'
|
|
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
// GET /api/aos/agency
|
|
// Returns all agency applications + approved agencies. Admin-only in practice
|
|
// (no scope check here because AOS is single-tenant dev mode).
|
|
export async function GET() {
|
|
try {
|
|
const [applications, agencies] = await Promise.all([
|
|
db.agencyApplication.findMany({
|
|
orderBy: { appliedAt: 'desc' },
|
|
include: { company: true },
|
|
}),
|
|
db.company.findMany({
|
|
where: { isAgency: true, agencyStatus: 'approved' },
|
|
orderBy: { agencyApprovedAt: 'desc' },
|
|
include: {
|
|
agencyClients: { select: { id: true, name: true, email: true } },
|
|
_count: { select: { agencyClients: true, licenses: true } },
|
|
},
|
|
}),
|
|
])
|
|
|
|
const pending = applications.filter((a) => a.status === 'pending')
|
|
const reviewed = applications.filter((a) => a.status !== 'pending')
|
|
|
|
return NextResponse.json({
|
|
applications: { pending, reviewed },
|
|
agencies,
|
|
stats: {
|
|
pending: pending.length,
|
|
approved: agencies.length,
|
|
totalApplications: applications.length,
|
|
},
|
|
})
|
|
} catch (err) {
|
|
const msg = err instanceof Error ? err.message : 'internal server error'
|
|
return NextResponse.json({ error: msg }, { status: 500 })
|
|
}
|
|
}
|