Skip to content

fix(bu-edit): restore 13 fields dropped by the one-document rewrite + guard required fields#34

Merged
samutpra merged 1 commit into
mainfrom
fix/bu-edit-missing-fields
Jul 16, 2026
Merged

fix(bu-edit): restore 13 fields dropped by the one-document rewrite + guard required fields#34
samutpra merged 1 commit into
mainfrom
fix/bu-edit-missing-fields

Conversation

@samutpra

Copy link
Copy Markdown
Contributor

Problem

Creating a Business Unit failed with HTTP 400 code field is required and there was no Code input on the page.

Root cause: the one-document rewrite (87d9f0f) deleted the per-section form components (BasicInfoSection, HotelInfoSection, CompanyInfoSection, DateTimeFormatsSection) and re-rendered fields by hand — silently dropping 13 fields that still reach formData but had no control. They could never be set on create nor edited. Existing values round-trip safely (loaded + sent back), so this was a create/edit UX break, not data loss.

Dropped fields: code, hotel_name, company_tel, company_email, company_address_line2, company_sub_district, company_district, company_province, company_postal_code, company_latitude, company_longitude, long_time_format, short_time_format.

Changes

  • BusinessUnitDocument.tsx — add all 13 fields back. Split the merged "Company & tax" group into distinct Company and Tax groups; prefix company address labels so hotel/company fields no longer share aria-labels (a11y).
  • BusinessUnitEdit.tsx — add validateRequired(): a blank cluster_id / code / name no longer fires a doomed request (backend requires these per swagger /api-system/business-units POST). Errors surface in the banner + inline, aborting before the POST (satisfies CLAUDE.md rule 14).
  • TestsBusinessUnitDocument.test.tsx covers all 38 editable fields as a mechanical regression guard; BusinessUnitEdit.test.tsx adds block-on-missing-code and create-when-valid cases.

Verification

  • Full Vitest suite: 495/495 passing
  • End-to-end against local backend: Code field editable, all 13 fields render, empty-create blocked with 0 POST, valid create POSTs 201.

Follow-up (separate, pre-existing)

InlineField select can't commit its first-displayed option when formData starts empty (no matching option → browser shows option 0 but state stays ''). Fix would add an empty placeholder option as default. Not in scope here.

🤖 Generated with Claude Code

… guard required fields

The one-document rewrite (87d9f0f) deleted the per-section form components
and re-rendered fields by hand, silently dropping 13 that reach formData but
had no control — so they could never be set on create nor edited. `code` was
one of them, which made every create fail with HTTP 400 "code field is
required".

- BusinessUnitDocument.tsx: add the 13 missing fields back (code, hotel_name,
  company_tel/email, full company address, long/short time format). Split the
  merged "Company & tax" group into distinct Company and Tax groups and prefix
  company address labels so hotel/company fields no longer share aria-labels.
- BusinessUnitEdit.tsx: add validateRequired() so a blank cluster_id/code/name
  never fires a doomed request (backend requires these per swagger). Surfaces
  errors in the banner and inline, aborting before the POST.
- Tests: BusinessUnitDocument.test.tsx covers all 38 editable fields (mechanical
  regression guard); BusinessUnitEdit.test.tsx adds block-on-missing-code and
  create-when-valid cases.

Verified end-to-end against the local backend: create now POSTs 201.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@samutpra
samutpra merged commit 6d8926e into main Jul 16, 2026
5 checks passed
@samutpra
samutpra deleted the fix/bu-edit-missing-fields branch July 16, 2026 08:07
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