Skip to content

Commit

Permalink
Merge pull request #234 from virtualidentityag/fix/OB-9487-prevent-mu…
Browse files Browse the repository at this point in the history
…ltiple-registrations

fix: disable submit button while submitting
  • Loading branch information
janrembold authored Feb 5, 2024
2 parents 7546162 + 7ddcb4f commit f63d6e4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/RegistrationDigi/RegistrationFormDigi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const RegistrationFormDigi = ({
const [form] = Form.useForm();

const [topics, setTopics] = useState([] as TopicsDataInterface[]);
const [submitting, setSubmitting] = useState(false);
const [formErrors, setFormErrors] = useState([]); // This needs to be an array to trigger the changes on accordion
const [registrationWithSuccess, setRegistrationWithSuccess] =
useState(false);
Expand Down Expand Up @@ -149,6 +150,8 @@ export const RegistrationFormDigi = ({
// When the form is submitted we send the data to the API
const onSubmit = useCallback(
(formValues) => {
setSubmitting(true);

const finalValues = {
username: formValues.username,
password: encodeURIComponent(formValues.password),
Expand Down Expand Up @@ -187,7 +190,8 @@ export const RegistrationFormDigi = ({
]);
setIsUsernameAlreadyInUse(true);
}
});
})
.finally(() => setSubmitting(false));
},
[consultant, form, settings, tenant, urlQuery]
);
Expand Down Expand Up @@ -493,7 +497,7 @@ export const RegistrationFormDigi = ({
</div>

<Button
disabled={formErrors.length > 0}
disabled={formErrors.length > 0 || submitting}
className="registrationFormDigi__Submit"
buttonHandle={() => form.submit()}
item={buttonItemSubmit}
Expand Down

0 comments on commit f63d6e4

Please sign in to comment.