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
This commit is contained in:
39
apps/app/src/lib/event-status.ts
Normal file
39
apps/app/src/lib/event-status.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
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'
|
||||
}
|
||||
Reference in New Issue
Block a user