Skip to content

Conversation

@tomrndom
Copy link

  • use field array to manage extra questions values
  • disable new value if it's not completed

ref:
https://app.clickup.com/t/86b7nv7x6
https://app.clickup.com/t/86b7nv9zf

Signed-off-by: Tomás Castillo [email protected]

… if value is not completed

Signed-off-by: Tomás Castillo <[email protected]>
@tomrndom tomrndom requested a review from smarcet December 10, 2025 21:04
@smarcet smarcet requested a review from Copilot December 15, 2025 15:14
Copy link

@smarcet smarcet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@smarcet smarcet merged commit 8309405 into master Dec 15, 2025
8 checks passed
Copy link

Copilot AI left a 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 handleAddValue and handleRemoveValue functions with Formik's FieldArray push and remove methods
  • Added validation error messages to the Yup validation schema for required fields
  • Implemented areExtraQuestionsIncomplete function 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() === ""
Copy link

Copilot AI Dec 15, 2025

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() === "".

Suggested change
(eq) => eq.name?.trim() === "" || eq.label?.trim() === ""
(eq) => eq.value?.trim() === "" || eq.label?.trim() === ""

Copilot uses AI. Check for mistakes.
Comment on lines +253 to +262
onClick={() => {
const valueToRemove = formik.values.values[index];
if (valueToRemove.id) {
deleteSponsorExtraQuestionValue(
formik.values.id,
valueToRemove.id
);
}
remove(index);
}}
Copy link

Copilot AI Dec 15, 2025

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.

Copilot uses AI. Check for mistakes.
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.

3 participants