p5.js-web-editor/client/modules/User/components/LoginForm.jsx
ov 9694719e02
Login form spanish translation (#1535)
* NewFolderModal spanish translation
 translations.json (both languages EN - ES)
 changes in NewFileForm.jsx and NewFileModal.jsx to link the new keys.
* Login Form translation
* SocialAuthButton.jsx Changes
Interpolation in translations.json
2020-08-12 16:24:29 +02:00

66 lines
2 KiB
JavaScript

import PropTypes from 'prop-types';
import React from 'react';
import { withTranslation } from 'react-i18next';
import i18n from 'i18next';
import Button from '../../../common/Button';
import { domOnlyProps } from '../../../utils/reduxFormUtils';
function LoginForm(props) {
const {
fields: { email, password }, handleSubmit, submitting, pristine
} = props;
return (
<form className="form" onSubmit={handleSubmit(props.validateAndLoginUser.bind(this, props.previousPath))}>
<p className="form__field">
<label htmlFor="email" className="form__label">{props.t('LoginForm.UsernameOrEmail')}</label>
<input
className="form__input"
aria-label={props.t('LoginForm.UsernameOrEmailARIA')}
type="text"
id="email"
{...domOnlyProps(email)}
/>
{email.touched && email.error && <span className="form-error">{email.error}</span>}
</p>
<p className="form__field">
<label htmlFor="password" className="form__label">{props.t('LoginForm.Password')}</label>
<input
className="form__input"
aria-label={props.t('LoginForm.PasswordARIA')}
type="password"
id="password"
{...domOnlyProps(password)}
/>
{password.touched && password.error && <span className="form-error">{password.error}</span>}
</p>
<Button
type="submit"
disabled={submitting || pristine}
>{props.t('LoginForm.Submit')}
</Button>
</form>
);
}
LoginForm.propTypes = {
fields: PropTypes.shape({
email: PropTypes.object.isRequired,
password: PropTypes.object.isRequired
}).isRequired,
handleSubmit: PropTypes.func.isRequired,
validateAndLoginUser: PropTypes.func.isRequired,
submitting: PropTypes.bool,
pristine: PropTypes.bool,
invalid: PropTypes.bool,
previousPath: PropTypes.string.isRequired,
t: PropTypes.func.isRequired
};
LoginForm.defaultProps = {
submitting: false,
pristine: true,
invalid: false
};
export default withTranslation()(LoginForm);