Skip to content

Commit

Permalink
DX-856 Fix Validation and Import Order in Account Verification Form
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuscal-Ashman committed Oct 25, 2024
1 parent bd114a3 commit fdb2441
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { useFormState } from 'react-use-form-state';
import { axios } from '../../utils/axios';
import { Button } from '../Button';
import { TextField } from '../TextField';
import { validateEmail } from '../../utils/validation';
import { ErrorMessage } from '../ErrorMessage';
import { useAccountVerificationForm } from './AccountVerificationFormProvider';
import { StepLogo } from './StepLogo';
import { StepHeading } from './StepHeading';


export function AccountVerificationFormStep0SignUp() {
const { goToStep, cancel, updateAccountVerificationFormState, goForward } = useAccountVerificationForm();

Expand All @@ -26,7 +28,15 @@ export function AccountVerificationFormStep0SignUp() {

function handleSubmit(e) {
e.preventDefault();

const emailValue = formState.values.email;
if (!validateEmail(emailValue)) {
setError({ message: 'Please enter a valid email address.' });
return;
}

setSubmitting(true);

axios
.post('/api/create-user', formState.values)
.then( async res => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function AccountVerificationFormStep3LoadingSteps() {
} else {
console.log("The newJobId variable is null or undefined.");
}
}, []);
}, [setJobId]);

return (
<div className="flex flex-col space-y-10 sm:space-y-12">
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3390,7 +3390,7 @@ react-is@^16.13.1:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==

react-use-form-state@^18.2.0:
react-use-form-state@^0.13.2:
version "0.13.2"
resolved "https://registry.yarnpkg.com/react-use-form-state/-/react-use-form-state-0.13.2.tgz#907327a2479b07e51fe4f58df93fc19767cf6261"
integrity sha512-bP2H5V6bBFZCJIrbpUcahvJX/f5rGueOvIjg818sq3wg0aX6BFz70u81yhaSg2aCZq0aF3R8eMc2MRWIjr5yhw==
Expand Down

0 comments on commit fdb2441

Please sign in to comment.