refactor: add translation for texts in sign up page
This commit is contained in:
@@ -429,7 +429,6 @@ input StepInput {
|
|||||||
type User {
|
type User {
|
||||||
id: String
|
id: String
|
||||||
fullName: String
|
fullName: String
|
||||||
password: String
|
|
||||||
email: String
|
email: String
|
||||||
role: String
|
role: String
|
||||||
createdAt: String
|
createdAt: String
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate, Link as RouterLink } from 'react-router-dom';
|
||||||
import { useMutation } from '@apollo/client';
|
import { useMutation } from '@apollo/client';
|
||||||
import Paper from '@mui/material/Paper';
|
import Paper from '@mui/material/Paper';
|
||||||
|
import Link from '@mui/material/Link';
|
||||||
import Typography from '@mui/material/Typography';
|
import Typography from '@mui/material/Typography';
|
||||||
import LoadingButton from '@mui/lab/LoadingButton';
|
import LoadingButton from '@mui/lab/LoadingButton';
|
||||||
|
|
||||||
@@ -10,7 +11,6 @@ import * as URLS from 'config/urls';
|
|||||||
import { LOGIN } from 'graphql/mutations/login';
|
import { LOGIN } from 'graphql/mutations/login';
|
||||||
import Form from 'components/Form';
|
import Form from 'components/Form';
|
||||||
import TextField from 'components/TextField';
|
import TextField from 'components/TextField';
|
||||||
import { Link } from './style.ee';
|
|
||||||
|
|
||||||
function renderFields(props: { loading: boolean }) {
|
function renderFields(props: { loading: boolean }) {
|
||||||
const { loading = false } = props;
|
const { loading = false } = props;
|
||||||
@@ -52,8 +52,10 @@ function renderFields(props: { loading: boolean }) {
|
|||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
|
|
||||||
<Typography variant="body1" align="center" mt={3}>
|
<Typography variant="body1" align="center" mt={3}>
|
||||||
Don't have an Automatisch account yet?
|
Don't have an Automatisch account yet?
|
||||||
<Link to={URLS.SIGNUP}>Sign Up</Link>
|
<Link component={RouterLink} to={URLS.SIGNUP} underline="none">
|
||||||
|
Sign up
|
||||||
|
</Link>
|
||||||
</Typography>
|
</Typography>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@@ -1,7 +0,0 @@
|
|||||||
import { styled } from '@mui/material/styles';
|
|
||||||
import { Link as RouterLink } from 'react-router-dom';
|
|
||||||
|
|
||||||
export const Link = styled(RouterLink)(({theme}) => ({
|
|
||||||
textDecoration: 'underline',
|
|
||||||
marginLeft: theme.spacing(0.5)
|
|
||||||
}));
|
|
@@ -13,15 +13,16 @@ import Form from 'components/Form';
|
|||||||
import TextField from 'components/TextField';
|
import TextField from 'components/TextField';
|
||||||
import { yupResolver } from '@hookform/resolvers/yup';
|
import { yupResolver } from '@hookform/resolvers/yup';
|
||||||
import { LOGIN } from 'graphql/mutations/login';
|
import { LOGIN } from 'graphql/mutations/login';
|
||||||
|
import useFormatMessage from 'hooks/useFormatMessage';
|
||||||
|
|
||||||
const validationSchema = yup.object().shape({
|
const validationSchema = yup.object().shape({
|
||||||
fullName: yup.string().trim().required(),
|
fullName: yup.string().trim().required('signupForm.mandatoryInput'),
|
||||||
email: yup.string().trim().email().required(),
|
email: yup.string().trim().email().required('signupForm.mandatoryInput'),
|
||||||
password: yup.string().required(),
|
password: yup.string().required('signupForm.mandatoryInput'),
|
||||||
confirmPassword: yup
|
confirmPassword: yup
|
||||||
.string()
|
.string()
|
||||||
.required()
|
.required('signupForm.mandatoryInput')
|
||||||
.oneOf([yup.ref('password')], 'Passwords must match'),
|
.oneOf([yup.ref('password')], 'signupForm.passwordMustMatch'),
|
||||||
});
|
});
|
||||||
|
|
||||||
const initialValues = {
|
const initialValues = {
|
||||||
@@ -34,6 +35,7 @@ const initialValues = {
|
|||||||
function SignUpForm() {
|
function SignUpForm() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const authentication = useAuthentication();
|
const authentication = useAuthentication();
|
||||||
|
const formatMessage = useFormatMessage();
|
||||||
const [createUser] = useMutation(CREATE_USER);
|
const [createUser] = useMutation(CREATE_USER);
|
||||||
const [login, { loading }] = useMutation(LOGIN);
|
const [login, { loading }] = useMutation(LOGIN);
|
||||||
|
|
||||||
@@ -75,7 +77,7 @@ function SignUpForm() {
|
|||||||
}}
|
}}
|
||||||
gutterBottom
|
gutterBottom
|
||||||
>
|
>
|
||||||
Sign Up
|
{formatMessage('signupForm.title')}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
<Form
|
<Form
|
||||||
@@ -86,7 +88,7 @@ function SignUpForm() {
|
|||||||
render={({ formState: { errors, touchedFields } }) => (
|
render={({ formState: { errors, touchedFields } }) => (
|
||||||
<>
|
<>
|
||||||
<TextField
|
<TextField
|
||||||
label="Full Name"
|
label={formatMessage('signupForm.fullNameFieldLabel')}
|
||||||
name="fullName"
|
name="fullName"
|
||||||
fullWidth
|
fullWidth
|
||||||
margin="dense"
|
margin="dense"
|
||||||
@@ -94,44 +96,63 @@ function SignUpForm() {
|
|||||||
data-test="fullName-text-field"
|
data-test="fullName-text-field"
|
||||||
error={touchedFields.fullName && !!errors?.fullName}
|
error={touchedFields.fullName && !!errors?.fullName}
|
||||||
helperText={
|
helperText={
|
||||||
(touchedFields.fullName && errors?.fullName?.message) || ''
|
touchedFields.fullName && errors?.fullName?.message
|
||||||
|
? formatMessage(errors?.fullName?.message, {
|
||||||
|
inputName: formatMessage('signupForm.fullNameFieldLabel'),
|
||||||
|
})
|
||||||
|
: ''
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
label="Email"
|
label={formatMessage('signupForm.emailFieldLabel')}
|
||||||
name="email"
|
name="email"
|
||||||
fullWidth
|
fullWidth
|
||||||
margin="dense"
|
margin="dense"
|
||||||
autoComplete="email"
|
autoComplete="email"
|
||||||
data-test="email-text-field"
|
data-test="email-text-field"
|
||||||
error={touchedFields.email && !!errors?.email}
|
error={touchedFields.email && !!errors?.email}
|
||||||
helperText={(touchedFields.email && errors?.email?.message) || ''}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextField
|
|
||||||
fullWidth
|
|
||||||
name="password"
|
|
||||||
label="Password"
|
|
||||||
margin="dense"
|
|
||||||
type="password"
|
|
||||||
error={touchedFields.password && !!errors?.password}
|
|
||||||
helperText={
|
helperText={
|
||||||
(touchedFields.password && errors?.password?.message) || ''
|
touchedFields.email && errors?.email?.message
|
||||||
|
? formatMessage(errors?.email?.message, {
|
||||||
|
inputName: formatMessage('signupForm.emailFieldLabel'),
|
||||||
|
})
|
||||||
|
: ''
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
|
label={formatMessage('signupForm.passwordFieldLabel')}
|
||||||
|
name="password"
|
||||||
fullWidth
|
fullWidth
|
||||||
|
margin="dense"
|
||||||
|
type="password"
|
||||||
|
error={touchedFields.password && !!errors?.password}
|
||||||
|
helperText={
|
||||||
|
touchedFields.password && errors?.password?.message
|
||||||
|
? formatMessage(errors?.password?.message, {
|
||||||
|
inputName: formatMessage('signupForm.passwordFieldLabel'),
|
||||||
|
})
|
||||||
|
: ''
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextField
|
||||||
|
label={formatMessage('signupForm.confirmPasswordFieldLabel')}
|
||||||
name="confirmPassword"
|
name="confirmPassword"
|
||||||
label="Confirm Password"
|
fullWidth
|
||||||
margin="dense"
|
margin="dense"
|
||||||
type="password"
|
type="password"
|
||||||
error={touchedFields.confirmPassword && !!errors?.confirmPassword}
|
error={touchedFields.confirmPassword && !!errors?.confirmPassword}
|
||||||
helperText={
|
helperText={
|
||||||
(touchedFields.confirmPassword &&
|
touchedFields.confirmPassword &&
|
||||||
errors?.confirmPassword?.message) ||
|
errors?.confirmPassword?.message
|
||||||
''
|
? formatMessage(errors?.confirmPassword?.message, {
|
||||||
|
inputName: formatMessage(
|
||||||
|
'signupForm.confirmPasswordFieldLabel'
|
||||||
|
),
|
||||||
|
})
|
||||||
|
: ''
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -144,7 +165,7 @@ function SignUpForm() {
|
|||||||
fullWidth
|
fullWidth
|
||||||
data-test="signUp-button"
|
data-test="signUp-button"
|
||||||
>
|
>
|
||||||
Sign Up
|
{formatMessage('signupForm.submit')}
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
@@ -94,5 +94,13 @@
|
|||||||
"webhookUrlInfo.title": "Your webhook URL",
|
"webhookUrlInfo.title": "Your webhook URL",
|
||||||
"webhookUrlInfo.description": "You'll need to configure your application with this webhook URL.",
|
"webhookUrlInfo.description": "You'll need to configure your application with this webhook URL.",
|
||||||
"webhookUrlInfo.helperText": "We've generated a custom webhook URL for you to send requests to. <link>Learn more about webhooks</link>.",
|
"webhookUrlInfo.helperText": "We've generated a custom webhook URL for you to send requests to. <link>Learn more about webhooks</link>.",
|
||||||
"webhookUrlInfo.copy": "Copy"
|
"webhookUrlInfo.copy": "Copy",
|
||||||
|
"signupForm.title": "Sign up",
|
||||||
|
"signupForm.fullNameFieldLabel": "Full name",
|
||||||
|
"signupForm.emailFieldLabel": "Email",
|
||||||
|
"signupForm.passwordFieldLabel": "Password",
|
||||||
|
"signupForm.confirmPasswordFieldLabel": "Confirm password",
|
||||||
|
"signupForm.submit": "Sign up",
|
||||||
|
"signupForm.passwordMustMatch": "Passwords must match.",
|
||||||
|
"signupForm.mandatoryInput": "{inputName} is required."
|
||||||
}
|
}
|
Reference in New Issue
Block a user