Files
logbuch/src/lib/api-problem.ts
T
Matthias G 35a572c037 Switch an entry status straight from the table
The list showed the status but only the editor could change it. Each row
now carries the next sensible step and names the blockers when publishing
is not possible. Also real umlauts in the API texts.
2026-08-01 13:49:34 +02:00

39 lines
1.3 KiB
TypeScript

import { problem } from './problem'
import type { ApiEntryError } from './api-entries'
const statuses: Record<ApiEntryError, number> = {
forbidden: 403,
project_unknown: 404,
project_not_allowed: 403,
type_unknown: 422,
audience_not_allowed: 403,
title_missing: 400,
title_too_long: 400,
teaser_too_long: 400,
slug_invalid: 400,
blocks_invalid: 400,
too_many_blocks: 400,
not_found: 404,
already_published: 409,
}
const details: Record<ApiEntryError, string> = {
forbidden: 'Dieser Zugang darf nicht schreiben.',
project_unknown: 'Das Projekt gibt es nicht.',
project_not_allowed: 'Dieser Zugang ist an ein anderes Projekt gebunden.',
type_unknown: 'Diese Beitragsart gibt es nicht oder sie ist abgeschaltet.',
audience_not_allowed: 'Dieser Zugang darf diese Zielgruppe nicht setzen.',
title_missing: 'Der Titel fehlt.',
title_too_long: 'Der Titel ist zu lang.',
teaser_too_long: 'Der Anreisser ist zu lang.',
slug_invalid: 'Der Slug enthaelt unerlaubte Zeichen.',
blocks_invalid: 'Mindestens ein Block hat einen unbekannten Typ oder fehlende Felder.',
too_many_blocks: 'Zu viele Bloecke.',
not_found: 'Nicht gefunden.',
already_published: 'Der Beitrag ist bereits veröffentlicht und lässt sich so nicht mehr ändern.',
}
export function entryProblem(error: ApiEntryError): Response {
return problem(statuses[error], error, details[error])
}