feat: Copy event to new — pre-fill form from existing event - #44
feat: Copy event to new — pre-fill form from existing event#44jerry-shimizutech wants to merge 1 commit into
Conversation
Adds a Copy button (blue) to each row in the Events admin list. Clicking it opens the New Event form pre-populated with all data from the selected event, except: - Name gets '(Copy)' suffix - Slug, dates, live stream URL are cleared (must be set fresh) - Status resets to 'draft' - Nested schedule items and prize categories are stripped of IDs so they create fresh records (not update existing ones) Addresses inbox request: 'when creating another event, we can copy a previous event to have it pre-filled and not starting from scratch'
✅ Deploy Preview for marianas-open ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Addresses inbox request: "when creating another event, we can copy a previous event to have it pre-filled and not starting from scratch"
What it does
Adds a Copy button (blue,
Copyicon from lucide-react) to each event row in the Events admin list — both desktop table and mobile card views.Behavior
(Copy)suffixdraftWhy this matters
The Marianas Open runs annual events in multiple cities (Guam, Japan, etc.) that share the same structure. Copying a previous event saves 30+ minutes of data entry per event.
Testing
Greptile Summary
This PR adds a "Copy to new event" button (desktop table + mobile card views) that pre-populates the New Event form from an existing event, saving significant data-entry time for recurring annual events.
Key changes:
handleCopyEventfunction inEventsAdmin.tsxusing the existingeventToFormhelperslug,date,end_date,live_stream_url/active,status) are correctly cleared on copyevent_schedule_items_attributesandprize_categories_attributesso nested records are created fresh rather than updating originalsvenue_highlights,registration_steps,travel_items, etc.) are carried over as-is — these have no IDs at the type level so no stripping is neededwindow.scrollTo({ top: 0, behavior: 'smooth' })provides immediate UX feedbackevent_accommodationsare not part ofEventFormDataand are therefore not copied — this is pre-existing behaviour and likely intentionalConfidence Score: 5/5
eventToFormhelper, clears all identity/uniqueness fields before setting state, and strips nested-record IDs to prevent accidental overwrites of originals. The other nested JSON arrays (venue_highlights,registration_steps, etc.) correctly require no ID stripping per their type definitions. No existing logic paths are modified.Important Files Changed
handleCopyEventfunction and Copy buttons (desktop + mobile) that pre-fill the New Event form from an existing event, clearing identity fields and stripping nested-record IDs. Implementation is clean and consistent with existing edit patterns.Sequence Diagram
sequenceDiagram actor Admin participant EventsAdmin participant eventToForm participant FormState Admin->>EventsAdmin: clicks Copy button on event row EventsAdmin->>eventToForm: eventToForm(event) eventToForm-->>EventsAdmin: copied: EventFormData (with IDs) EventsAdmin->>EventsAdmin: clear identity fields (slug, date, end_date, status, live_stream_*) EventsAdmin->>EventsAdmin: strip id from event_schedule_items_attributes EventsAdmin->>EventsAdmin: strip id from prize_categories_attributes EventsAdmin->>FormState: setForm(copied) EventsAdmin->>FormState: setEditing('new') EventsAdmin->>Admin: window.scrollTo top (smooth) Admin->>EventsAdmin: fills slug + dates, clicks Save EventsAdmin->>EventsAdmin: handleSave() → api.admin.createEvent(form)Reviews (1): Last reviewed commit: "feat: Copy event to new — pre-fill new e..." | Re-trigger Greptile