fix(#257): extract GuardianForm; use MAX_GUARDIANS from constants - #311
Merged
icentedward76-sketch merged 1 commit intoAug 31, 2026
Conversation
…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.
|
@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. |
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #257.
There was no
GuardianForm.tsxcomponent — the guardian-input UI was inlined inwill/new/page.tsxusingMAX_GUARDIANSfrom@/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)guardians, callbacks (onAdd,onRemove,onUpdate,onResolve), validation state, and resolution maps as props+ Add guardianbutton disabled atguardians.length >= MAX_GUARDIANSwhereMAX_GUARDIANSis imported from@/lib/constants— never hardcodedsrc/app/will/new/page.tsxGuardianFormimport<GuardianForm>passing all required propsbeneficiariesstate outside the component)tests/unit/GuardianForm.test.tsx(new, 11 tests)length < MAX_GUARDIANS, disabled atlength === MAX_GUARDIANSonAddcalled when under limit; not called when disabledaria-labelreflects current count andMAX_GUARDIANS@/lib/constants(regression guard: if constants.ts changes, test tracks it)onRemoveindextopErrorand per-row error displayVerification
tsc --noEmitclean for all modified files.