934bee2aec
- lib/admin-votes.ts: listVoteSites / createVoteSite / deleteVoteSite. - Routes /api/admin/votes (POST) y /api/admin/votes/[id] (DELETE), guard isAdmin. - Página /admin/votes (AdminVotesManager: crear/listar/borrar) + enlace en dashboard. - Conecta con la página de votación (/vote-points) ya existente. Verificado: guardas (307/403), CRUD del write layer OK (con env cargado). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
12 lines
489 B
TypeScript
12 lines
489 B
TypeScript
import { getSession } from '@/lib/session'
|
|
import { isAdmin } from '@/lib/admin'
|
|
import { deleteVoteSite } from '@/lib/admin-votes'
|
|
|
|
export async function DELETE(_request: Request, { params }: { params: Promise<{ id: string }> }) {
|
|
const session = await getSession()
|
|
if (!(await isAdmin(session))) return Response.json({ success: false, error: 'forbidden' }, { status: 403 })
|
|
const { id } = await params
|
|
await deleteVoteSite(Number(id))
|
|
return Response.json({ success: true })
|
|
}
|