-
Notifications
You must be signed in to change notification settings - Fork 2k
Small tweak to user invite flow #4825
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
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
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
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); | ||
}); | ||
}, |
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.
style: Using async/await with .then() is an anti-pattern. Either use pure async/await or pure promises.
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); | |
} | |
}, |
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.