CC-49: Fix how forced values are applied in forms#325
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThis PR refactors form validation across the application by introducing a form handle pattern to replace react-hook-form's typed 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/MatchResultForm/MatchResultForm.tsx`:
- Line 124: The validateForm call is building the schema from the unmerged
formData so forcedValues (e.g., forcedValues.gameSystem) can be ignored; first
merge the data (merge({}, formData, forcedValues)) into a single variable (e.g.,
mergedData) and then call createSchema(mergedData.gameSystem) and validateForm
with that schema and mergedData
(validateForm(createSchema(mergedData.gameSystem), mergedData, form)) so
validation runs against the correct, post-merge game-system schema.
In `@src/utils/validateForm.ts`:
- Line 15: The duplicate call to clearErrors() is redundant—remove the extra
invocation from validateForm by deleting the form.clearErrors() line inside the
validateForm function so only the Form component's clearErrors() (in Form.tsx)
remains; locate the validateForm function and the form.clearErrors() call and
remove that single call to avoid double-clearing while keeping the Form.tsx
clearErrors() behavior intact.
- Around line 5-8: The FormHandle interface currently uses a plain string for
field names which loses type safety; update the interface (FormHandle) to be
generic (e.g., FormHandle<T>) and change setError to accept the typed field path
used by react-hook-form (use the library's FieldPath/Path utility for the name
parameter and the appropriate FieldError-like error type) while keeping
clearErrors unchanged; update all usages/call sites to pass the form data type
to FormHandle so invalid field names are caught at compile time.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 36cf5459-f260-4768-91ae-7ca219bee87f
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (18)
package.jsonsrc/components/ChangeEmailForm/ChangeEmailForm.tsxsrc/components/ChangePasswordForm/ChangePasswordForm.tsxsrc/components/ListCommentForm/ListCommentForm.tsxsrc/components/ListForm/ListForm.tsxsrc/components/MatchResultForm/MatchResultForm.module.scsssrc/components/MatchResultForm/MatchResultForm.schema.tssrc/components/MatchResultForm/MatchResultForm.tsxsrc/components/MatchResultForm/components/PlayerField/PlayerField.module.scsssrc/components/MatchResultForm/components/PlayerField/PlayerField.tsxsrc/components/MatchResultProvider/actions/useCreateAction.tsxsrc/components/MatchResultProvider/components/MatchResultPhotoForm/MatchResultPhotoForm.tsxsrc/components/TournamentCompetitorForm/TournamentCompetitorForm.tsxsrc/components/TournamentForm/TournamentForm.tsxsrc/components/TournamentPairingConfigForm/TournamentPairingConfigForm.tsxsrc/components/TournamentRegistrationForm/TournamentRegistrationForm.tsxsrc/components/generic/Form/Form.tsxsrc/utils/validateForm.ts
💤 Files with no reviewable changes (1)
- src/components/MatchResultForm/MatchResultForm.module.scss
Fixes CC-49
Summary by CodeRabbit
New Features
Bug Fixes
Style