Add transition buttons from allowed_transitions with Dutch labels, confirmation dialog, TanStack mutation + cache invalidation, and 422/generic error handling via notification store. Made-with: Cursor
40 lines
980 B
TypeScript
40 lines
980 B
TypeScript
import type { EventStatus } from '@/types/event'
|
|
|
|
const STATUS_ORDER: Record<EventStatus, number> = {
|
|
draft: 0,
|
|
published: 1,
|
|
registration_open: 2,
|
|
buildup: 3,
|
|
showday: 4,
|
|
teardown: 5,
|
|
closed: 6,
|
|
}
|
|
|
|
export const EVENT_STATUS_LABEL_NL: Record<EventStatus, string> = {
|
|
draft: 'Concept',
|
|
published: 'Gepubliceerd',
|
|
registration_open: 'Registratie open',
|
|
buildup: 'Opbouw',
|
|
showday: 'Showdag',
|
|
teardown: 'Afbouw',
|
|
closed: 'Afgesloten',
|
|
}
|
|
|
|
export function eventStatusLabelNl(status: EventStatus): string {
|
|
return EVENT_STATUS_LABEL_NL[status]
|
|
}
|
|
|
|
/** UI styling: forward in lifecycle, rollback, or closing the event. */
|
|
export function transitionVisualKind(
|
|
currentStatus: EventStatus,
|
|
targetStatus: EventStatus,
|
|
): 'forward' | 'backward' | 'dangerous' {
|
|
if (targetStatus === 'closed')
|
|
return 'dangerous'
|
|
|
|
const current = STATUS_ORDER[currentStatus]
|
|
const next = STATUS_ORDER[targetStatus]
|
|
|
|
return next < current ? 'backward' : 'forward'
|
|
}
|