-
Notifications
You must be signed in to change notification settings - Fork 4
fix: use field array to manage extra questions values #717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… if value is not completed Signed-off-by: Tomás Castillo <[email protected]>
smarcet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the extra questions value management in the sponsor general form to use Formik's FieldArray component instead of custom handlers, improving form state management and validation. The change also adds validation error messages and implements logic to disable adding new values when existing ones are incomplete.
- Replaced custom
handleAddValueandhandleRemoveValuefunctions with Formik'sFieldArraypushandremovemethods - Added validation error messages to the Yup validation schema for required fields
- Implemented
areExtraQuestionsIncompletefunction to disable the "Add Value" button when current values are incomplete
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const areExtraQuestionsIncomplete = () => { | ||
| if (formik.errors.values) return true; | ||
| return formik.values.values.some( | ||
| (eq) => eq.name?.trim() === "" || eq.label?.trim() === "" |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The areExtraQuestionsIncomplete function is checking for eq.name?.trim() === "" and eq.label?.trim() === "", but the values array contains objects with value and label fields, not name and label. This should be checking eq.value?.trim() === "" instead of eq.name?.trim() === "".
| (eq) => eq.name?.trim() === "" || eq.label?.trim() === "" | |
| (eq) => eq.value?.trim() === "" || eq.label?.trim() === "" |
| onClick={() => { | ||
| const valueToRemove = formik.values.values[index]; | ||
| if (valueToRemove.id) { | ||
| deleteSponsorExtraQuestionValue( | ||
| formik.values.id, | ||
| valueToRemove.id | ||
| ); | ||
| } | ||
| remove(index); | ||
| }} |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removed IconButton properties edge="end", sx={{ color: "#666" }}, and disableRipple should be preserved in the new implementation to maintain consistent styling and behavior with the rest of the UI.
ref:
https://app.clickup.com/t/86b7nv7x6
https://app.clickup.com/t/86b7nv9zf
Signed-off-by: Tomás Castillo [email protected]