accounts-frontend/src/components/auth/Login.jsx

65 lines
1.7 KiB
React
Raw Normal View History

import React, { PropTypes } from 'react';
import { FormattedMessage as Message } from 'react-intl';
import Helmet from 'react-helmet';
import buttons from 'components/ui/buttons.scss';
import { Input } from 'components/ui/Form';
import BaseAuthBody from './BaseAuthBody';
import messages from './Login.messages';
import passwordMessages from './Password.messages';
class Body extends BaseAuthBody {
static propTypes = {
...BaseAuthBody.propTypes,
login: PropTypes.func.isRequired,
auth: PropTypes.shape({
error: PropTypes.string,
login: PropTypes.shape({
login: PropTypes.stirng
})
})
};
render() {
return (
<div>
{this.renderErrors()}
<Input {...this.bindField('login')}
icon="envelope"
autoFocus
required
placeholder={messages.emailOrUsername}
/>
</div>
);
}
onFormSubmit() {
this.props.login(this.serialize());
}
}
export default function Login() {
return {
Title: () => ( // TODO: separate component for PageTitle
<Message {...messages.loginTitle}>
{(msg) => <span>{msg}<Helmet title={msg} /></span>}
</Message>
),
Body,
Footer: () => (
<button className={buttons.green} type="submit">
<Message {...messages.next} />
</button>
),
Links: () => (
<a href="#">
<Message {...passwordMessages.forgotPassword} />
</a>
)
};
}