Skip to content

Conversation

Weves
Copy link
Contributor

@Weves Weves commented Jun 4, 2025

Description

[Provide a brief description of the changes in this PR]

How Has This Been Tested?

[Describe the tests you ran to verify your changes]

Backporting (check the box to trigger backport action)

Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.

  • This PR should be backported (make sure to check that the backport attempt succeeds)
  • [Optional] Override Linear Check

@Weves Weves requested a review from a team as a code owner June 4, 2025 15:04
Copy link

vercel bot commented Jun 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
internal-search ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 4, 2025 3:06pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Improved form submission handling in the BulkAdd component by adding proper state management during form submission.

  • Added formikBag.setSubmitting(true/false) to properly disable submit button during form processing
  • Ensured submit state is always reset in finally block to prevent button from staying disabled on errors
  • Added keyboard submit handling via Enter key while maintaining submission state management
  • Improved email validation with regex pattern before submission

1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines 80 to 94
handleSubmit: async (values: FormValues, formikBag) => {
const emails = values.emails.trim().split(WHITESPACE_SPLIT);
await addUsers("/api/manage/admin/users", { arg: emails }).then((res) => {
if (res.ok) {
formikBag.props.onSuccess();
} else {
formikBag.props.onFailure(res);
}
});
formikBag.setSubmitting(true);
await addUsers("/api/manage/admin/users", { arg: emails })
.then((res) => {
if (res.ok) {
formikBag.props.onSuccess();
} else {
formikBag.props.onFailure(res);
}
})
.finally(() => {
formikBag.setSubmitting(false);
});
},
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Using async/await with .then() is an anti-pattern. Either use pure async/await or pure promises.

Suggested change
handleSubmit: async (values: FormValues, formikBag) => {
const emails = values.emails.trim().split(WHITESPACE_SPLIT);
await addUsers("/api/manage/admin/users", { arg: emails }).then((res) => {
if (res.ok) {
formikBag.props.onSuccess();
} else {
formikBag.props.onFailure(res);
}
});
formikBag.setSubmitting(true);
await addUsers("/api/manage/admin/users", { arg: emails })
.then((res) => {
if (res.ok) {
formikBag.props.onSuccess();
} else {
formikBag.props.onFailure(res);
}
})
.finally(() => {
formikBag.setSubmitting(false);
});
},
handleSubmit: async (values: FormValues, formikBag) => {
const emails = values.emails.trim().split(WHITESPACE_SPLIT);
formikBag.setSubmitting(true);
try {
const res = await addUsers("/api/manage/admin/users", { arg: emails });
if (res.ok) {
formikBag.props.onSuccess();
} else {
formikBag.props.onFailure(res);
}
} finally {
formikBag.setSubmitting(false);
}
},

@Weves Weves merged commit 851e0b0 into main Jun 4, 2025
10 of 12 checks passed
@Weves Weves deleted the tenant-invite-improvement branch June 4, 2025 15:09
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.

1 participant