Skip to content

Commit

Permalink
updates on validation form
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfil3 committed Dec 28, 2023
1 parent 0714d48 commit 46cca9c
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 27 deletions.
6 changes: 2 additions & 4 deletions src/components/ForgotPasswordForm/ForgotPasswordForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function ForgotPasswordForm() {
validationSchema={forgotPasswordSchema}
onSubmit={onSubmit}
>
{({ errors, touched, isSubmitting, isValid }) => (
{({ errors, touched }) => (
<Form>
<FormikStyledField
type="email"
Expand All @@ -49,9 +49,7 @@ export default function ForgotPasswordForm() {
/>
<Error component="p" name="email" />

<Button type="submit" disabled={!isValid || isSubmitting}>
Send
</Button>
<Button type="submit">Send</Button>
</Form>
)}
</Formik>
Expand Down
6 changes: 2 additions & 4 deletions src/components/SignInForm/SignInForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function SignInForm() {
validationSchema={loginSchema}
onSubmit={onSubmit}
>
{({ errors, touched, isSubmitting, isValid }) => (
{({ errors, touched }) => (
<SignInFormikForm>
<FlexWrapper>
<FieldWrapper>
Expand Down Expand Up @@ -108,9 +108,7 @@ export default function SignInForm() {
</FieldWrapper>
</FlexWrapper>

<Button type="submit" disabled={!isValid || isSubmitting}>
Sign in
</Button>
<Button type="submit">Sign in</Button>
<ForgotLink to="/forgot-password">Forgot your password?</ForgotLink>
</SignInFormikForm>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function FormGenderAndAge({
validationSchema={genderAndAgeSchema}
onSubmit={onSubmit}
>
{({ errors, touched, isSubmitting, isValid }) => (
{({ errors, touched }) => (
<GenderAndAgeForm>
<Text>Gender</Text>
<GenderWrapper>
Expand Down Expand Up @@ -61,9 +61,7 @@ export default function FormGenderAndAge({
<Error component="p" name="age" />
</AgeWrapper>

<GenderAndAgeButton type="submit" disabled={!isValid || isSubmitting}>
Next
</GenderAndAgeButton>
<GenderAndAgeButton type="submit">Next</GenderAndAgeButton>
<BackButton onClick={handlePrevStep}>Back</BackButton>
</GenderAndAgeForm>
)}
Expand Down
6 changes: 2 additions & 4 deletions src/components/SignUpForm/FormGoal/FormGoal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function FormGoal({
validationSchema={goalSchema}
onSubmit={onSubmit}
>
{({ isValid, isSubmitting }) => (
{() => (
<GoalForm>
<FlexWrapper>
<Label>
Expand All @@ -44,9 +44,7 @@ export default function FormGoal({
<Error component="p" name="goal" />
</FlexWrapper>

<GoalButton type="submit" disabled={!isValid || isSubmitting}>
Next
</GoalButton>
<GoalButton type="submit">Next</GoalButton>
<BackButton onClick={handlePrevStep}>Back</BackButton>
</GoalForm>
)}
Expand Down
6 changes: 2 additions & 4 deletions src/components/SignUpForm/FormParameters/FormParameters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function FormParameters({
validationSchema={parametersSchema}
onSubmit={onSubmit}
>
{({ errors, touched, isSubmitting, isValid }) => (
{({ errors, touched }) => (
<ParametersForm>
<Label>
Height
Expand Down Expand Up @@ -64,9 +64,7 @@ export default function FormParameters({
<Error component="p" name="weight" />
</Label>

<ParametersButton type="submit" disabled={!isValid || isSubmitting}>
Next
</ParametersButton>
<ParametersButton type="submit">Next</ParametersButton>
<BackButton onClick={handlePrevStep}>Back</BackButton>
</ParametersForm>
)}
Expand Down
6 changes: 2 additions & 4 deletions src/components/SignUpForm/FormUserData/FormUserData.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function FormUserData({
validationSchema={registerSchema}
onSubmit={onSubmit}
>
{({ errors, touched, isValid, isSubmitting }) => (
{({ errors, touched }) => (
<SignUpFormikForm>
<FieldWrapper>
<SignUpField
Expand Down Expand Up @@ -110,9 +110,7 @@ export default function FormUserData({
</IconsWrapper>
</FieldWrapper>

<SignUpButton type="submit" disabled={!isValid || isSubmitting}>
Next
</SignUpButton>
<SignUpButton type="submit">Next</SignUpButton>
</SignUpFormikForm>
)}
</Formik>
Expand Down
6 changes: 4 additions & 2 deletions src/components/SignUpForm/SignUpForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ export default function SignUpForm({
try {
await dispatch(registration(userData)).unwrap();

toast.success('You have successfully signed up!');
toast.success(
'You have successfully signed up! \n A confirmation letter has been sent to your email, please check it!'
);
navigate('/signin');
} catch (error) {
toast.error(`Something went wrong! ${error.message}`);
toast.error(`Something went wrong! \n ${error.message}`);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/pages/SignInPage/SignInPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function SignInPage() {
<HeadlineFirst>Sign in</HeadlineFirst>
<HeadSecond>You need to login to use the service</HeadSecond>
<SignInForm />
<SubText>If you don't have an account yet</SubText>``
<SubText>If you don't have an account yet</SubText>
<SubLink to="/signup">Sign up</SubLink>
</TextWrapper>
</FlexBox>
Expand Down

0 comments on commit 46cca9c

Please sign in to comment.