Skip to content

feat: Copy event to new — pre-fill form from existing event - #44

Open
jerry-shimizutech wants to merge 1 commit into
mainfrom
feat/copy-event-from-previous
Open

feat: Copy event to new — pre-fill form from existing event#44
jerry-shimizutech wants to merge 1 commit into
mainfrom
feat/copy-event-from-previous

Conversation

@jerry-shimizutech

@jerry-shimizutech jerry-shimizutech commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

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, Copy icon from lucide-react) to each event row in the Events admin list — both desktop table and mobile card views.

Behavior

  • Clicking Copy opens the New Event form pre-populated with all data from the selected event
  • Auto-scrolls to the top of the page so the form is immediately visible
  • Fields cleared on copy (must be set fresh):
    • Name → appends (Copy) suffix
    • Slug → empty (required, must be unique)
    • Start date, end date → empty
    • Live stream URL, live stream active → cleared
    • Status → resets to draft
  • Nested records (schedule items, prize categories) are copied but IDs are stripped — so they create new records instead of updating the originals
  • Venue, registration info, travel, visa, prize pool, stars — all carried over

Why 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

  • Desktop: Events admin → click Copy icon on any event → verify form pre-populates
  • Mobile: Same flow on mobile card view
  • Create the copied event → verify new records created, not edits to original
  • TypeScript build: clean ✓

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:

  • New handleCopyEvent function in EventsAdmin.tsx using the existing eventToForm helper
  • Identity fields (slug, date, end_date, live_stream_url/active, status) are correctly cleared on copy
  • IDs are stripped from event_schedule_items_attributes and prize_categories_attributes so nested records are created fresh rather than updating originals
  • Other JSON-column arrays (venue_highlights, registration_steps, travel_items, etc.) are carried over as-is — these have no IDs at the type level so no stripping is needed
  • window.scrollTo({ top: 0, behavior: 'smooth' }) provides immediate UX feedback
  • Note: event_accommodations are not part of EventFormData and are therefore not copied — this is pre-existing behaviour and likely intentional

Confidence Score: 5/5

  • Safe to merge — the change is additive, well-scoped, and follows existing patterns without touching save/delete paths.
  • The implementation is a clean, isolated addition: a new handler + two button insertions. It correctly reuses the existing eventToForm helper, 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.
  • No files require special attention.

Important Files Changed

Filename Overview
web/src/pages/admin/EventsAdmin.tsx Adds handleCopyEvent function 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)
Loading

Reviews (1): Last reviewed commit: "feat: Copy event to new — pre-fill new e..." | Re-trigger Greptile

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'
@netlify

netlify Bot commented Mar 23, 2026

Copy link
Copy Markdown

Deploy Preview for marianas-open ready!

Name Link
🔨 Latest commit d4aebf2
🔍 Latest deploy log https://app.netlify.com/projects/marianas-open/deploys/69c12d0902fb360008d39786
😎 Deploy Preview https://deploy-preview-44--marianas-open.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Mar 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 46410700-84df-4caa-bcef-394fde4f41bf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/copy-event-from-previous

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jerry-shimizutech

Copy link
Copy Markdown
Contributor Author

@greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant