Skip to content

Commit

Permalink
Fix correction form reset (#1825)
Browse files Browse the repository at this point in the history
  • Loading branch information
junjun107 authored Oct 3, 2023
1 parent 86d012f commit 1b4d05e
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ function SuggestionDialog(props) {
const { values, touched, errors, handleChange, handleBlur, handleSubmit } =
props;

const { onClose, open, id } = props;
const handleCancel = () => onClose(false);
const { onClose, open, id, handleReset } = props;
const handleCancel = () => {
handleReset();
onClose(false);
};

return (
<Dialog
Expand Down Expand Up @@ -144,10 +147,10 @@ const SuggestionForm = withFormik({
tipsterEmail: tipsterEmail || "",
}),
validationSchema: Yup.object(validationsForm),
handleSubmit: (values, { props }) => {
handleSubmit: (values, formikBag) => {
const stakeholder = {
...DEFAULT_STAKEHOLDER,
...props.stakeholder,
...formikBag.stakeholder,
};

// Construct the suggestion by starting with the stakeholder record,
Expand All @@ -164,13 +167,14 @@ const SuggestionForm = withFormik({
return suggestionService
.post(altered)
.then(() => {
props.setToast({
formikBag.props.setToast({
message: "Thank you for your help!",
});
props.onClose(true);
formikBag.resetForm();
formikBag.props.onClose(true);
})
.catch(() => {
props.setToast({
formikBag.props.setToast({
message:
"Sorry, submitting your correction failed, please email us at the address on the About page.",
});
Expand Down

0 comments on commit 1b4d05e

Please sign in to comment.