Files
crewli/apps/app/src/lib/event-status.ts
bert.hausmans 1172c41d33 feat(app): event status transitions on detail header
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
2026-04-12 22:20:36 +02:00

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'
}