2016-02-13 20:58:47 +05:30
|
|
|
import React, { PropTypes } from 'react';
|
2016-01-16 17:36:22 +05:30
|
|
|
|
|
|
|
import { FormattedMessage as Message } from 'react-intl';
|
2016-01-16 18:05:12 +05:30
|
|
|
import Helmet from 'react-helmet';
|
2016-01-16 17:36:22 +05:30
|
|
|
|
|
|
|
import buttons from 'components/ui/buttons.scss';
|
2016-01-19 11:47:21 +05:30
|
|
|
import { Input } from 'components/ui/Form';
|
2016-01-16 17:36:22 +05:30
|
|
|
|
2016-02-13 20:58:47 +05:30
|
|
|
import BaseAuthBody from './BaseAuthBody';
|
2016-01-19 11:47:21 +05:30
|
|
|
import messages from './Login.messages';
|
|
|
|
import passwordMessages from './Password.messages';
|
2016-01-16 17:36:22 +05:30
|
|
|
|
2016-02-13 20:58:47 +05:30
|
|
|
class Body extends BaseAuthBody {
|
|
|
|
static propTypes = {
|
|
|
|
...BaseAuthBody.propTypes,
|
|
|
|
login: PropTypes.func.isRequired,
|
|
|
|
auth: PropTypes.shape({
|
|
|
|
error: PropTypes.string,
|
|
|
|
login: PropTypes.shape({
|
|
|
|
login: PropTypes.stirng
|
|
|
|
})
|
|
|
|
})
|
2016-01-31 18:29:38 +05:30
|
|
|
};
|
|
|
|
|
2016-02-13 20:58:47 +05:30
|
|
|
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() {
|
2016-01-31 18:29:38 +05:30
|
|
|
return {
|
|
|
|
Title: () => ( // TODO: separate component for PageTitle
|
|
|
|
<Message {...messages.loginTitle}>
|
|
|
|
{(msg) => <span>{msg}<Helmet title={msg} /></span>}
|
|
|
|
</Message>
|
|
|
|
),
|
2016-02-13 20:58:47 +05:30
|
|
|
Body,
|
|
|
|
Footer: () => (
|
|
|
|
<button className={buttons.green} type="submit">
|
2016-01-31 18:29:38 +05:30
|
|
|
<Message {...messages.next} />
|
|
|
|
</button>
|
|
|
|
),
|
|
|
|
Links: () => (
|
|
|
|
<a href="#">
|
|
|
|
<Message {...passwordMessages.forgotPassword} />
|
|
|
|
</a>
|
|
|
|
)
|
|
|
|
};
|
|
|
|
}
|