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:
@@ -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;
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user