1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
import { Component } from 'react';
import PropTypes from 'prop-types';
import { observer, PropTypes as MobxPropTypes } from 'mobx-react';
import { defineMessages, injectIntl } from 'react-intl';
import Form from '../../lib/Form';
import { required, email } from '../../helpers/validation-helpers';
import Input from '../ui/Input';
import Button from '../ui/Button';
import Link from '../ui/Link';
import Infobox from '../ui/Infobox';
import globalMessages from '../../i18n/globalMessages';
import { H1 } from '../ui/headline';
const messages = defineMessages({
headline: {
id: 'password.headline',
defaultMessage: 'Reset password',
},
emailLabel: {
id: 'password.email.label',
defaultMessage: 'Email address',
},
successInfo: {
id: 'password.successInfo',
defaultMessage: 'Your new password was sent to your email address',
},
noUser: {
id: 'password.noUser',
defaultMessage: 'No user with that email address was found',
},
signupLink: {
id: 'password.link.signup',
defaultMessage: 'Create a free account',
},
loginLink: {
id: 'password.link.login',
defaultMessage: 'Sign in to your account',
},
});
class Password extends Component {
static propTypes = {
onSubmit: PropTypes.func.isRequired,
isSubmitting: PropTypes.bool.isRequired,
signupRoute: PropTypes.string.isRequired,
loginRoute: PropTypes.string.isRequired,
status: MobxPropTypes.arrayOrObservableArray.isRequired,
};
form = (() => {
const { intl } = this.props;
return new Form({
fields: {
email: {
label: intl.formatMessage(messages.emailLabel),
value: '',
validators: [required, email],
},
},
},
intl,
)})();
submit(e) {
e.preventDefault();
this.form.submit({
onSuccess: form => {
this.props.onSubmit(form.values());
},
onError: () => {},
});
}
render() {
const { form } = this;
const { intl } = this.props;
const { isSubmitting, signupRoute, loginRoute, status } = this.props;
return (
<div className="auth__container">
<form className="franz-form auth__form" onSubmit={e => this.submit(e)}>
<Link to='/auth/welcome'><img src="./assets/images/logo.svg" className="auth__logo" alt="" /></Link>
<H1>{intl.formatMessage(messages.headline)}</H1>
{status.length > 0 && status.includes('sent') && (
<Infobox type="success" icon="checkbox-marked-circle-outline">
{intl.formatMessage(messages.successInfo)}
</Infobox>
)}
<Input field={form.$('email')} focus />
{status.length > 0 && status.includes('no-user') && (
<p className="error-message center">
{intl.formatMessage(messages.noUser)}
</p>
)}
{isSubmitting ? (
<Button
className="auth__button is-loading"
buttonType="secondary"
label={`${intl.formatMessage(globalMessages.submit)} ...`}
loaded={false}
disabled
/>
) : (
<Button
type="submit"
className="auth__button"
label={intl.formatMessage(globalMessages.submit)}
/>
)}
</form>
<div className="auth__links">
<Link to={loginRoute}>{intl.formatMessage(messages.loginLink)}</Link>
<Link to={signupRoute}>
{intl.formatMessage(messages.signupLink)}
</Link>
</div>
</div>
);
}
}
export default injectIntl(observer(Password));
|