Skip to content

Auto-delete empty ShowEvent after admin ShowEntry delete #252

@asku1990

Description

@asku1990

Description

Align admin show delete behavior with admin trial delete behavior.

When deleting a ShowEntry in admin manage flow:

  • Keep ShowEntry as the primary delete target.
  • After successful delete, count remaining ShowEntry rows for that ShowEvent.
  • If remaining count is 0, automatically delete the now-empty parent ShowEvent.
  • Do not add a separate “delete ShowEvent” user action.

Scope:

  • packages/db/admin/shows/manage/delete-show-entry.ts: add empty-parent cleanup in same transaction.
  • packages/server/admin/shows/manage/delete-show-entry.ts: return deletedShowEvent: boolean.
  • apps/web/app/actions/admin/shows/manage/delete-admin-show-entry.ts: pass through new response field.
  • apps/web/queries/admin/shows/manage/use-delete-admin-show-entry-mutation.ts: keep invalidation; ensure UI handles deleted parent.
  • apps/web/components/admin/shows/manage/**: if deletedShowEvent === true, clear selected event / fallback safely.
  • Update contracts and local index.ts exports accordingly.

Acceptance criteria

  • Admin can delete a single show result row.
  • Parent ShowEvent remains when other entries exist.
  • Parent ShowEvent is auto-deleted when last entry is removed.
  • No boundary violations (business logic in server, writes in db).
  • Tests cover success, not_found, event remains, event removed, and UI handling of deleted parent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions