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
|
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { observer } from 'mobx-react';
import { defineMessages, intlShape } from 'react-intl';
import Form from '../../lib/Form';
import { required } from '../../helpers/validation-helpers';
import Input from '../ui/Input';
import Button from '../ui/Button';
import Infobox from '../ui/Infobox';
import { globalError as globalErrorPropType } from '../../prop-types';
const messages = defineMessages({
headline: {
id: 'locked.headline',
defaultMessage: '!!!Locked',
},
info: {
id: 'locked.info',
defaultMessage: '!!!Ferdi is currently locked. Please unlock Ferdi with your password to see your messages.',
},
passwordLabel: {
id: 'locked.password.label',
defaultMessage: '!!!Password',
},
submitButtonLabel: {
id: 'locked.submit.label',
defaultMessage: '!!!Unlock',
},
invalidCredentials: {
id: 'locked.invalidCredentials',
defaultMessage: '!!!Password invalid',
},
});
export default @observer class Locked extends Component {
static propTypes = {
onSubmit: PropTypes.func.isRequired,
isSubmitting: PropTypes.bool.isRequired,
error: globalErrorPropType.isRequired,
};
static contextTypes = {
intl: intlShape,
};
form = new Form({
fields: {
password: {
label: this.context.intl.formatMessage(messages.passwordLabel),
value: '',
validators: [required],
type: 'password',
},
},
}, this.context.intl);
submit(e) {
e.preventDefault();
this.form.submit({
onSuccess: (form) => {
this.props.onSubmit(form.values());
},
onError: () => { },
});
}
render() {
const { form } = this;
const { intl } = this.context;
const {
isSubmitting,
error,
} = this.props;
return (
<div className="auth__container">
<form className="franz-form auth__form" onSubmit={e => this.submit(e)}>
<img
src="./assets/images/logo.svg"
className="auth__logo"
alt=""
/>
<h1>{intl.formatMessage(messages.headline)}</h1>
<Infobox type="warning">
{intl.formatMessage(messages.info)}
</Infobox>
<Input
field={form.$('password')}
showPasswordToggle
/>
{error.code === 'invalid-credentials' && (
<p className="error-message center">{intl.formatMessage(messages.invalidCredentials)}</p>
)}
{isSubmitting ? (
<Button
className="auth__button is-loading"
buttonType="secondary"
label={`${intl.formatMessage(messages.submitButtonLabel)} ...`}
loaded={false}
disabled
/>
) : (
<Button
type="submit"
className="auth__button"
label={intl.formatMessage(messages.submitButtonLabel)}
/>
)}
</form>
</div>
);
}
}
|