Link event staffing shifts to ticketed events with auto pre-fill

Shift.ticketedEventId (nullable FK to TicketedEvent) persists the
link between a staffing shift and its parent event. The shift list
response now includes the linked event (id, slug, title, date) so
the admin UI can show context without a second request.

The Create/Edit Shift drawer gains a conditional Event picker that
only appears when kind is EVENT_STAFFING. Picking an event pre-fills
the form's date, startTime, endTime, and location (venue name +
address) — and seeds the title with "Staff: {event.title}" only if
the title field is still empty, so hand-typed overrides aren't
stomped. Switching kind away from EVENT_STAFFING clears the link.

The shifts table's Kind tag wraps in a tooltip showing the linked
event title when one is present, so organizers can see at a glance
which staffing shifts belong to which event without opening the
drawer.

Bunker Admin
This commit is contained in:
2026-04-11 11:45:15 -06:00
parent 96ff2a85d6
commit 80321f04e7
6 changed files with 111 additions and 8 deletions

View File

@@ -0,0 +1,7 @@
-- AlterTable
ALTER TABLE "shifts" ADD COLUMN "ticketed_event_id" TEXT;
-- AddForeignKey
ALTER TABLE "shifts" ADD CONSTRAINT "shifts_ticketed_event_id_fkey" FOREIGN KEY ("ticketed_event_id") REFERENCES "ticketed_events"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@@ -876,6 +876,10 @@ model Shift {
cutId String?
cut Cut? @relation(fields: [cutId], references: [id], onDelete: SetNull)
// Event linkage (EVENT_STAFFING shifts)
ticketedEventId String? @map("ticketed_event_id")
ticketedEvent TicketedEvent? @relation("EventStaffingShifts", fields: [ticketedEventId], references: [id], onDelete: SetNull)
// Repeating shift series
seriesId String?
series ShiftSeries? @relation(fields: [seriesId], references: [id], onDelete: SetNull)
@@ -5009,11 +5013,12 @@ model TicketedEvent {
updatedAt DateTime @updatedAt @map("updated_at")
// Relations
createdBy User @relation("EventCreator", fields: [createdByUserId], references: [id])
meeting Meeting? @relation("EventMeeting", fields: [meetingId], references: [id], onDelete: SetNull)
ticketTiers TicketTier[] @relation("EventTiers")
tickets Ticket[] @relation("EventTickets")
checkIns CheckIn[] @relation("EventCheckIns")
createdBy User @relation("EventCreator", fields: [createdByUserId], references: [id])
meeting Meeting? @relation("EventMeeting", fields: [meetingId], references: [id], onDelete: SetNull)
ticketTiers TicketTier[] @relation("EventTiers")
tickets Ticket[] @relation("EventTickets")
checkIns CheckIn[] @relation("EventCheckIns")
staffingShifts Shift[] @relation("EventStaffingShifts")
@@index([status], map: "idx_ticketed_events_status")
@@index([date], map: "idx_ticketed_events_date")

View File

@@ -12,6 +12,7 @@ export const createShiftSchema = z.object({
isPublic: z.boolean().optional().default(false),
cutId: z.string().optional(),
kind: z.nativeEnum(ShiftKind).optional().default(ShiftKind.CANVASS),
ticketedEventId: z.string().optional(),
});
export const updateShiftSchema = z.object({
@@ -26,6 +27,7 @@ export const updateShiftSchema = z.object({
status: z.nativeEnum(ShiftStatus).optional(),
cutId: z.string().nullable().optional(),
kind: z.nativeEnum(ShiftKind).optional(),
ticketedEventId: z.string().nullable().optional(),
});
export const listShiftsSchema = z.object({

View File

@@ -73,6 +73,7 @@ export const shiftsService = {
orderBy,
include: {
cut: { select: { id: true, name: true } },
ticketedEvent: { select: { id: true, slug: true, title: true, date: true } },
meeting: { select: meetingSelect },
_count: {
select: {
@@ -134,6 +135,7 @@ export const shiftsService = {
isPublic: data.isPublic,
cutId: data.cutId,
kind: data.kind,
ticketedEventId: data.ticketedEventId,
createdBy: userId,
},
});