Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe('<IdentifierRegisterForm />', () => {
test('submit properly', async () => {
const { getByText, queryByText, container } = renderForm();
const submitButton = getByText('action.create_account');
const termsButton = getByText('description.agree_with_terms');

const usernameInput = container.querySelector('input[name=identifier]');

assert(usernameInput, new Error('username input not found'));
Expand All @@ -176,12 +176,9 @@ describe('<IdentifierRegisterForm />', () => {
expect(registerWithUsername).not.toBeCalled();
});

const agreeButton = getByText('Agree');
act(() => {
fireEvent.click(termsButton);
});

act(() => {
fireEvent.submit(submitButton);
fireEvent.click(agreeButton);
});

await waitFor(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ const IdentifierRegisterForm = ({ className, autoFocus, signUpMethods }: Props)

const onSubmitHandler = useCallback(
async (event?: React.FormEvent<HTMLFormElement>) => {
if (isSubmitting) {
return;
}

clearErrorMessage();

void handleSubmit(async ({ identifier: { type, value } }) => {
Expand Down Expand Up @@ -92,6 +96,7 @@ const IdentifierRegisterForm = ({ className, autoFocus, signUpMethods }: Props)
agreeToTermsPolicy,
clearErrorMessage,
handleSubmit,
isSubmitting,
navigateToSingleSignOn,
onSubmit,
setIdentifierInputValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ const IdentifierSignInForm = ({ className, autoFocus, signInMethods }: Props) =>

const onSubmitHandler = useCallback(
async (event?: React.FormEvent<HTMLFormElement>) => {
if (isSubmitting) {
return;
}

clearErrorMessage();

void handleSubmit(async ({ identifier: { type, value } }) => {
Expand All @@ -96,6 +100,7 @@ const IdentifierSignInForm = ({ className, autoFocus, signInMethods }: Props) =>
agreeToTermsPolicy,
clearErrorMessage,
handleSubmit,
isSubmitting,
navigateToSingleSignOn,
onSubmit,
setIdentifierInputValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ const PasswordSignInForm = ({ className, autoFocus, signInMethods }: Props) => {

const onSubmitHandler = useCallback(
async (event?: React.FormEvent<HTMLFormElement>) => {
if (isSubmitting) {
return;
}

clearErrorMessage();

await handleSubmit(async ({ identifier: { type, value }, password }) => {
Expand Down Expand Up @@ -92,6 +96,7 @@ const PasswordSignInForm = ({ className, autoFocus, signInMethods }: Props) => {
agreeToTermsPolicy,
clearErrorMessage,
handleSubmit,
isSubmitting,
navigateToSingleSignOn,
onSubmit,
setIdentifierInputValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ const SingleSignOnForm = ({ isTermsAndPrivacyCheckboxVisible }: Props) => {
*/
event?.preventDefault();

if (isSubmitting) {
return;
}

/**
* Check if the user has agreed to the terms and privacy policy when the policy is set to `Manual`.
*/
Expand All @@ -66,7 +70,7 @@ const SingleSignOnForm = ({ isTermsAndPrivacyCheckboxVisible }: Props) => {

await handleSubmit(async ({ identifier: { value } }) => onSubmit(value, true))(event);
},
[agreeToTermsPolicy, clearErrorMessage, handleSubmit, onSubmit, termsValidation]
[agreeToTermsPolicy, clearErrorMessage, handleSubmit, isSubmitting, onSubmit, termsValidation]
);

return (
Expand Down
6 changes: 5 additions & 1 deletion packages/experience/src/containers/SetPassword/Lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,17 @@ const Lite = ({ className, autoFocus, onSubmit, errorMessage, clearErrorMessage

const onSubmitHandler = useCallback(
(event?: React.FormEvent<HTMLFormElement>) => {
if (isSubmitting) {
return;
}

clearErrorMessage?.();

void handleSubmit(async (data) => {
await onSubmit(data.newPassword);
})(event);
},
[clearErrorMessage, handleSubmit, onSubmit]
[clearErrorMessage, handleSubmit, isSubmitting, onSubmit]
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ const SetPassword = ({

const onSubmitHandler = useCallback(
(event?: React.FormEvent<HTMLFormElement>) => {
if (isSubmitting) {
return;
}

clearErrorMessage?.();

void handleSubmit(async (data) => {
await onSubmit(data.newPassword);
})(event);
},
[clearErrorMessage, handleSubmit, onSubmit]
[clearErrorMessage, handleSubmit, isSubmitting, onSubmit]
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ const IdentifierProfileForm = ({

const onSubmitHandler = useCallback(
(event?: React.FormEvent<HTMLFormElement>) => {
if (isSubmitting) {
return;
}

clearErrorMessage?.();

void handleSubmit(async ({ identifier: { type, value } }) => {
Expand All @@ -72,7 +76,7 @@ const IdentifierProfileForm = ({
await onSubmit?.(type, value);
})(event);
},
[clearErrorMessage, handleSubmit, onSubmit]
[clearErrorMessage, handleSubmit, isSubmitting, onSubmit]
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ const ForgotPasswordForm = ({ className, autoFocus, defaultValue = '', enabledTy

const onSubmitHandler = useCallback(
async (event?: React.FormEvent<HTMLFormElement>) => {
if (isSubmitting) {
return;
}

clearErrorMessage();

void handleSubmit(async ({ identifier: { type, value } }) => {
Expand All @@ -72,7 +76,7 @@ const ForgotPasswordForm = ({ className, autoFocus, defaultValue = '', enabledTy
await onSubmit({ identifier: type, value });
})(event);
},
[clearErrorMessage, handleSubmit, onSubmit, setForgotPasswordIdentifierInputValue]
[clearErrorMessage, handleSubmit, isSubmitting, onSubmit, setForgotPasswordIdentifierInputValue]
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ const PasswordForm = ({

const onSubmitHandler = useCallback(
async (event?: React.FormEvent<HTMLFormElement>) => {
if (isSubmitting) {
return;
}

clearErrorMessage();

void handleSubmit(async ({ identifier: { type, value }, password }) => {
Expand All @@ -83,7 +87,7 @@ const PasswordForm = ({
});
})(event);
},
[clearErrorMessage, handleSubmit, onSubmit, setIdentifierInputValue]
[clearErrorMessage, handleSubmit, isSubmitting, onSubmit, setIdentifierInputValue]
);

return (
Expand Down
Loading