Skip to content

BEJ-103: admin trial event and result creation - #340

Draft
asku1990 wants to merge 29 commits into
developfrom
feature/bej-103-admin-trial-event-and-result-creation
Draft

BEJ-103: admin trial event and result creation#340
asku1990 wants to merge 29 commits into
developfrom
feature/bej-103-admin-trial-event-and-result-creation

Conversation

@asku1990

@asku1990 asku1990 commented Jul 21, 2026

Copy link
Copy Markdown
Owner

ref bej-103

Summary

Integration pull request for the staged BEJ-103 implementation of admin trial event and manual result creation.

Each implementation gate is developed and reviewed in its own branch and pull request targeting this integration branch. Approved gates are merged here, and this pull request will be merged into develop only after the complete BEJ-103 workflow is finished and validated.

Implemented gates

E1 — Event workspace

  • Add a dedicated /admin/trials/[trialEventId] route.
  • Reuse the existing event details and result management UI on a stable event URL.
  • Add explicit loading, not-found, retry, navigation, and deletion states.
  • Add an Open event page action from the trials master-detail view.
  • Preserve existing event editing, result editing, PDF generation, and result deletion behavior.

E2 — Event creation and empty-event lifecycle

  • Add full-page admin trial event creation.
  • Persist a newly created event before any results exist.
  • Open the created event in its dedicated workspace.
  • Preserve an event when its final result is deleted.
  • Allow explicit deletion only for an empty event.
  • Return stable errors for missing, duplicate, and non-empty events.

R1 — Manual result backend foundation

  • Add manual trial entry request and response contracts.
  • Add an authenticated admin Server Action for manual trial entry creation.
  • Add shared registration normalization and validation.
  • Create TrialEntry, TrialEra, and TrialEraLisatieto rows atomically.
  • Link results through DogRegistration when a matching dog exists while allowing unknown registrations to remain unlinked.
  • Use canonical identity:
    • SKL:<sklKoeId>|REG:<canonicalRegistration>
  • Add database-backed duplicate protection and stable conflict errors.
  • Add MANUAL_ADMIN as a canonical trial source.
  • Define authoritative reconciliation where a later Koiratietokanta import replaces manual business data while preserving technical identity.
  • Store trial event dates using PostgreSQL DATE semantics and serialize them as timezone-free YYYY-MM-DD values.

Remaining gate

R2 — Manual result UI and workflow

R2 will add the full-page result creation form and connect it to the approved R1 backend contract, including:

  • registration entry;
  • result, era, judge, note, and lisätieto sections;
  • localized validation and stable error mappings;
  • Save and add another and Save and finish workflows;
  • dirty-form navigation protection;
  • query invalidation and navigation back to the event workspace;
  • the user-visible changelog entry for manual result creation.

Migration note

This branch updates existing Prisma migration files to reflect the intended final schema, including the trial source enum and PostgreSQL DATE storage for trial event dates.

There is currently no production data or deployed production migration history that must be preserved, so these migration edits are intentional and do not require corrective forward migrations.

Validation

The staged implementation includes focused coverage for:

  • workspace routing and event loading states;
  • event creation and empty-event deletion rules;
  • authorization and stable Server Action errors;
  • canonical registration handling;
  • manual result input validation;
  • atomic persistence and duplicate-race handling;
  • manual-to-Koiratietokanta reconciliation;
  • date-only conversion and trial search behavior.

Each gate must pass lint, typecheck, tests, coverage checks, and review before being merged into this integration branch.

Checklist

  • E1 event workspace merged.
  • E2 event creation and empty-event lifecycle merged.
  • R1 manual result backend foundation merged.
  • R2 manual result UI and workflow completed.
  • Final integration review completed.
  • Ready to merge into develop.

@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
beagle-db-v2 Ignored Ignored Preview Aug 4, 2026 5:14pm

asku1990 added 2 commits July 21, 2026 11:00
  Implement BEJ-103 Gate E1 with a stable full-page
  workspace for an
  existing trial event at /admin/trials/[trialEventId].

  - reuse the existing event summary, result list, edit
    dialogs, PDF action,
    and result deletion
  - add loading, not-found, generic error, and retry
    states
  - link the selected event to its workspace with
    centralized route helpers
  - preserve the current final-result deletion lifecycle
  - add Finnish and Swedish translations and focused
    tests
  - update trial-management documentation and the
    changelog

Refs: BEJ-103
@asku1990 asku1990 changed the title feat/create-trials-planning feat(admin): add trial event workspace Jul 21, 2026
asku1990 added 9 commits July 21, 2026 12:45
heading wrapper

  Remove an unnecessary layout wrapper around the trial
  event workspace
  heading without changing its appearance or behaviour.

ref bej-103
  Implement BEJ-103 Gate E2 with full-page trial event creation
  and explicit management of empty events.

  - add contracts, Server Actions, mutations, and persistence use cases
    for creating and deleting trial events
  - require a positive SKL event ID, date, and place during creation
  - default new events to the current Helsinki business date
  - resolve active rule windows through the shared DB repository
  - preserve an event when its final result is deleted
  - allow explicit deletion only for events without results
  - add localized confirmation and toast feedback for event deletion
  - reuse event form fields without changing existing edit behavior
  - retain empty events in admin views while excluding them publicly
  - add focused web, server, DB, and integration coverage
  - update trial-management documentation and the changelog

  Refs: BEJ-103
…lifecycle

feat(admin-trials): add event creation and empty-event lifecycle
  - add contracts, server action, service, and atomic persistence for
    manual trial entries
  - share normalized entry validation between create and update flows
  - reject duplicate registrations, lisätieto rows, and per-era
    lisätieto values
  - link manually created results to known dog registrations
  - allow API upserts to replace matching manual results authoritatively
  - store trial event dates as PostgreSQL DATE values
  - add MANUAL_ADMIN trial source tagging and update trial documentation
  - cover creation, validation, identity, date-only, and API overwrite
    behavior

ref bej-103
…t-backend

BEJ-103 R1: manual trial entry backend foundation
@asku1990 asku1990 changed the title feat(admin): add trial event workspace BEJ-103: admin trial event and result creation Jul 22, 2026
asku1990 added 15 commits July 22, 2026 22:47
  Add the full-page result creation route with reusable entry, era, and
  lisätieto sections.

  Support saving another result or returning to the event workspace,
  prefill event judge details, and protect unsaved form changes during
  navigation and page unload.

  Route newly created events directly to their first result form and
  invalidate affected admin, trial, dog-profile, and statistics queries
  after successful creation.

  Return safe structured validation details, identify rejected lisätieto
  rows, persist integer row ordering, and omit unused rows from create
  requests.

  Add Finnish and Swedish messages, workflow tests, feature
  documentation,
  and the follow-up plan for rule-window-aware result fields.

  ref bej-103
  Remove the unreliable browser Back recovery based on asynchronous
  history.forward() and history.back() calls.

  Keep confirmation for explicit internal navigation and native unload
  protection for refresh or tab close. Ignore modified and new-tab link
  clicks, ensure confirmed actions run only once, and add focused tests
  and documentation for the intentionally unguarded browser Back
  behavior.

  ref BEJ-103
  Validate trial entry integer fields against PostgreSQL Int bounds
  before
  payload construction so oversized values cannot be silently saved as
  null.

  Cover create and edit flows with boundary, overflow, and long-input
  tests.

  ref BEJ-103
feat(admin-trials): add event-scoped manual result entry workflow
  Resolve the manual result-create field set from the trial event’s
  persisted
  rule window.

  - add trialRuleWindowId to admin event details
  - configure and verify the current 2023+ score, era, and lisätieto
    fields
  - hide obsolete tja and pin score fields for current rules
  - use Ajotaito for the current rule period
  - align lisätieto codes, parts, input types, and marker persistence
    with the PDF
  - retain a warned legacy fallback for older and unknown rule windows
  - preserve existing result-edit behavior

  ref bej-103
…creation

feat(trials): make result creation rule-window aware
  Organize manual result creation into collapsible cards following the
  official trial PDF domain structure without copying its matrix layout.

  Add a searchable, grouped Lisätiedot workspace with responsive desktop
  and mobile editors, accessible focus handling, localized controls, and
  stable reset behavior. Keep R3A field visibility, draft ownership,
  serialization, validation, mutations, navigation protection, and
  editing
  behavior unchanged.

  Files:
  - CHANGELOG.md
  -
    apps/web/components/admin/trials/admin-trial-entry-create-page-client.tsx
  -
    apps/web/components/admin/trials/internal/__tests__/entry-meta-section.test.tsx
  -
    apps/web/components/admin/trials/internal/__tests__/era-section.test.tsx
  -
    apps/web/components/admin/trials/internal/__tests__/result-create-card.test.tsx
  -
    apps/web/components/admin/trials/internal/entry-meta-basic-fields.tsx
  - apps/web/components/admin/trials/internal/entry-meta-field.tsx
  -
    apps/web/components/admin/trials/internal/entry-meta-judge-fields.tsx
  - apps/web/components/admin/trials/internal/entry-meta-loss-fields.tsx
  -
    apps/web/components/admin/trials/internal/entry-meta-result-fields.tsx
  -
    apps/web/components/admin/trials/internal/entry-meta-score-fields.tsx
  - apps/web/components/admin/trials/internal/entry-meta-section.tsx
  - apps/web/components/admin/trials/internal/era-section.tsx
  - apps/web/components/admin/trials/internal/lisatiedot-workspace.tsx
  - apps/web/components/admin/trials/internal/result-create-card.tsx
  - apps/web/components/ui/sheet.tsx
  -
    apps/web/hooks/admin/trials/manage/__tests__/use-result-create-workspace-mobile.test.ts
  -
    apps/web/hooks/admin/trials/manage/use-result-create-workspace-mobile.ts
  -
    apps/web/lib/admin/trials/__tests__/lisatiedot-workspace-state.test.ts
  -
    apps/web/lib/admin/trials/__tests__/result-create-field-registry.test.ts
  - apps/web/lib/admin/trials/entry-edit-config.ts
  - apps/web/lib/admin/trials/lisatiedot-workspace-state.ts
  - apps/web/lib/admin/trials/result-create-field-registry.ts
  - apps/web/lib/i18n/messages/admin/trials/manage.ts
  - docs/features/admin-trial-management.md

  Ref BEJ-103
  Remove unfinished Lisätiedot search, filtering, bulk expansion
  controls,
  and selected-row chips. Keep PDF-domain groups individually
  collapsible
  with shared desktop/mobile row activation and draft ownership.

  Update reducer tests, accessibility labels, translations, and admin
  trial
  documentation to reflect the simpler workflow.

  Validation already run successfully: focused tests, web typecheck,
  targeted ESLint, and git diff --check.
  Remove the unreachable reducer reset action and its test. Add rendered
  workspace coverage for PDF-domain ordering, collapsible groups,
  active-row
  editor rendering, and accessible remove labels.

  Align the changelog, UX planning documentation, and PR description
  with the
  simplified Lisätiedot workflow.

  ref bej-103
…on-ux

feat(trials): redesign result creation workspace
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