Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name field validations and confirm password field #982

Merged
Merged
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
2 changes: 1 addition & 1 deletion public/locales/bg/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"account": {
"email": "Email",
"new-password": "Нова парола",
"confirm-password": "Потвърди нова парола",
"confirm-password": "Потвърди парола",
"previous-password": "Стара парола",
"first-name": "Име",
"last-name": "Фамилия",
Expand Down
11 changes: 11 additions & 0 deletions public/locales/en/auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,16 @@
"forgotten-password": {
"instructions": "To reset your password, please type your email address below. We will then send you an email with instructions to follow."
}
},
"account": {
"email": "Email",
"new-password": "New password",
"confirm-password": "Confirm password",
"previous-password": "Previous password",
"first-name": "First name",
"last-name": "Last name",
"phone": "Phone",
"company": "Company",
"message": "Message"
}
}
10 changes: 7 additions & 3 deletions src/components/auth/register/RegisterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import GenericForm from 'components/common/form/GenericForm'
import SubmitButton from 'components/common/form/SubmitButton'
import FormTextField from 'components/common/form/FormTextField'
import PasswordField from 'components/common/form/PasswordField'
import { email, password } from 'common/form/validation'
import { email, password, name } from 'common/form/validation'

export type RegisterFormData = {
firstName: string
Expand All @@ -25,10 +25,11 @@ const validationSchema: yup.SchemaOf<RegisterFormData> = yup
.object()
.defined()
.shape({
firstName: yup.string().min(3).max(100).required(),
lastName: yup.string().min(3).max(100).required(),
firstName: name.required(),
lastName: name.required(),
email: email.required(),
password: password.required(),
'confirm-password': yup.string().oneOf([yup.ref('password')], 'validation:password-match'),
})

const defaults: RegisterFormData = {
Expand Down Expand Up @@ -100,6 +101,9 @@ export default function RegisterForm({ initialValues = defaults }: RegisterFormP
<Grid item xs={12}>
<PasswordField />
</Grid>
<Grid item xs={12}>
<PasswordField name={'confirm-password'} label={'auth:account.confirm-password'} />
</Grid>
<Grid item xs={12}>
<SubmitButton fullWidth label="auth:cta.register" loading={loading} />
</Grid>
Expand Down