Skip to content

fix(#257): extract GuardianForm; use MAX_GUARDIANS from constants - #311

Merged
icentedward76-sketch merged 1 commit into
SoroWill:mainfrom
wendyamoni-creator:fix/257-guardian-form-max-guardians
Aug 31, 2026
Merged

fix(#257): extract GuardianForm; use MAX_GUARDIANS from constants#311
icentedward76-sketch merged 1 commit into
SoroWill:mainfrom
wendyamoni-creator:fix/257-guardian-form-max-guardians

Conversation

@wendyamoni-creator

Copy link
Copy Markdown
Contributor

Summary

Closes #257.

There was no GuardianForm.tsx component — the guardian-input UI was inlined in will/new/page.tsx using MAX_GUARDIANS from @/lib/constants (correctly). This PR creates the component so the logic is testable and reusable, and ensures the limit is always sourced from constants, not a hardcoded value.

Changes

src/components/GuardianForm.tsx (new)

  • Controlled fieldset component accepting guardians, callbacks (onAdd, onRemove, onUpdate, onResolve), validation state, and resolution maps as props
  • + Add guardian button disabled at guardians.length >= MAX_GUARDIANS where MAX_GUARDIANS is imported from @/lib/constants — never hardcoded
  • Exact same UI behaviour as the previous inline code

src/app/will/new/page.tsx

  • Added GuardianForm import
  • Replaced the ~100-line inline step-3 guardian fieldset with <GuardianForm> passing all required props
  • Guardian-beneficiary overlap warning stays in the page (it cross-references beneficiaries state outside the component)

tests/unit/GuardianForm.test.tsx (new, 11 tests)

  • Add button enabled when length < MAX_GUARDIANS, disabled at length === MAX_GUARDIANS
  • onAdd called when under limit; not called when disabled
  • aria-label reflects current count and MAX_GUARDIANS
  • Limit sourced from @/lib/constants (regression guard: if constants.ts changes, test tracks it)
  • Remove button count and onRemove index
  • topError and per-row error display

Verification

✓ tests/unit/GuardianForm.test.tsx (11 tests)

tsc --noEmit clean for all modified files.

…from constants

GuardianForm.tsx is a new controlled component that extracts the
guardian-input section that was previously inlined in will/new/page.tsx.
It imports MAX_GUARDIANS from @/lib/constants as the single source of
truth, so the Add guardian button is disabled at exactly the same limit
the rest of the app (guardianValidation.ts, will/new/page.tsx,
GuardianPanel.tsx) and the on-chain contract enforce.

Changes:
- src/components/GuardianForm.tsx (new): controlled fieldset component
  with Add/Remove/Update/Resolve callbacks; disables Add at
  guardians.length >= MAX_GUARDIANS (from @/lib/constants, never
  hardcoded).
- src/app/will/new/page.tsx: add GuardianForm import; replace the ~100-
  line inline fieldset in step 3 with <GuardianForm> passing all
  required props. The guardian-beneficiary overlap warning remains in
  the page because it cross-references beneficiaries state.
- tests/unit/GuardianForm.test.tsx (new): 11 tests covering the
  enabled/disabled boundary at exactly MAX_GUARDIANS, onAdd/onRemove
  callbacks, aria-label accuracy, and validation error display.
@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

@wendyamoni-creator is attempting to deploy a commit to the icentedward76-sketch's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@wendyamoni-creator Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@icentedward76-sketch
icentedward76-sketch merged commit aa4951f into SoroWill:main Aug 31, 2026
0 of 3 checks passed
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.

GuardianForm hardcodes its own MAX_GUARDIANS = 5, conflicting with lib/constants.ts's MAX_GUARDIANS = 3 used elsewhere

2 participants