2016-05-02 13:34:23 +05:30
|
|
|
import React from 'react';
|
|
|
|
|
2016-05-22 19:31:31 +05:30
|
|
|
import { FormattedMessage as Message, FormattedRelative as Relative } from 'react-intl';
|
2016-05-02 13:34:23 +05:30
|
|
|
|
2016-05-15 02:23:58 +05:30
|
|
|
import messages from './errorsDict.intl.json';
|
2016-05-02 13:34:23 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
resolve(error) {
|
2016-05-22 19:31:31 +05:30
|
|
|
let payload = {};
|
|
|
|
|
|
|
|
if (error.type) {
|
|
|
|
payload = error.payload;
|
|
|
|
error = error.type;
|
|
|
|
}
|
|
|
|
return errorsMap[error] ? errorsMap[error](payload) : error;
|
2016-05-02 13:34:23 +05:30
|
|
|
}
|
2016-05-02 14:50:50 +05:30
|
|
|
};
|
2016-05-02 13:34:23 +05:30
|
|
|
|
|
|
|
const errorsMap = {
|
|
|
|
'error.login_required': () => <Message {...messages.loginRequired} />,
|
|
|
|
'error.login_not_exist': () => <Message {...messages.loginNotExist} />,
|
|
|
|
'error.password_required': () => <Message {...messages.passwordRequired} />,
|
|
|
|
|
2016-05-02 14:50:50 +05:30
|
|
|
'error.password_invalid': () => <Message {...messages.invalidPassword} />,
|
2016-05-22 13:23:40 +05:30
|
|
|
'error.old_hash_strategy': () => <Message {...messages.oldHashStrategy} />,
|
2016-05-02 13:34:23 +05:30
|
|
|
'error.password_incorrect': () => (
|
|
|
|
<span>
|
|
|
|
<Message {...messages.invalidPassword} />
|
|
|
|
<br/>
|
|
|
|
<Message {...messages.suggestResetPassword} values={{
|
|
|
|
link: (
|
|
|
|
<a href="#">
|
|
|
|
<Message {...messages.forgotYourPassword} />
|
|
|
|
</a>
|
|
|
|
)
|
|
|
|
}} />
|
|
|
|
</span>
|
|
|
|
),
|
|
|
|
|
|
|
|
'error.username_required': () => <Message {...messages.usernameRequired} />,
|
2016-05-10 10:00:43 +05:30
|
|
|
'error.username_invalid': () => <Message {...messages.usernameInvalid} />,
|
|
|
|
'error.username_too_short': () => <Message {...messages.usernameTooShort} />,
|
|
|
|
'error.username_too_long': () => <Message {...messages.usernameTooLong} />,
|
2016-05-02 18:43:18 +05:30
|
|
|
'error.username_not_available': () => <Message {...messages.usernameUnavailable} />,
|
2016-05-10 10:00:43 +05:30
|
|
|
|
2016-05-02 13:34:23 +05:30
|
|
|
'error.email_required': () => <Message {...messages.emailRequired} />,
|
2016-05-10 10:00:43 +05:30
|
|
|
'error.email_too_long': () => <Message {...messages.emailToLong} />,
|
2016-05-02 13:34:23 +05:30
|
|
|
'error.email_invalid': () => <Message {...messages.emailInvalid} />,
|
|
|
|
'error.email_is_tempmail': () => <Message {...messages.emailIsTempmail} />,
|
|
|
|
'error.email_not_available': () => (
|
|
|
|
<span>
|
|
|
|
<Message {...messages.emailNotAvailable} />
|
|
|
|
<br/>
|
|
|
|
<Message {...messages.suggestResetPassword} values={{
|
|
|
|
link: (
|
|
|
|
<a href="#">
|
|
|
|
<Message {...messages.forgotYourPassword} />
|
|
|
|
</a>
|
|
|
|
)
|
|
|
|
}} />
|
|
|
|
</span>
|
|
|
|
),
|
|
|
|
|
|
|
|
'error.rePassword_required': () => <Message {...messages.rePasswordRequired} />,
|
|
|
|
'error.password_too_short': () => <Message {...messages.passwordTooShort} />,
|
|
|
|
'error.rePassword_does_not_match': () => <Message {...messages.passwordsDoesNotMatch} />,
|
|
|
|
'error.rulesAgreement_required': () => <Message {...messages.rulesAgreementRequired} />,
|
|
|
|
'error.you_must_accept_rules': () => this.errorsMap['error.rulesAgreement_required'](),
|
|
|
|
'error.key_required': () => <Message {...messages.keyRequired} />,
|
|
|
|
'error.key_is_required': () => this.errorsMap['error.key_required'](),
|
|
|
|
'error.key_not_exists': () => <Message {...messages.keyNotExists} />,
|
|
|
|
|
|
|
|
'error.newPassword_required': () => <Message {...messages.newPasswordRequired} />,
|
|
|
|
'error.newRePassword_required': () => <Message {...messages.newRePasswordRequired} />,
|
2016-05-15 02:23:58 +05:30
|
|
|
'error.newRePassword_does_not_match': () => <Message {...messages.passwordsDoesNotMatch} />,
|
|
|
|
|
|
|
|
'error.account_not_activated': () => <Message {...messages.accountNotActivated} />,
|
|
|
|
|
2016-05-22 19:31:31 +05:30
|
|
|
'error.email_frequency': (props) => <Message {...messages.emailFrequency} values={{
|
|
|
|
time: <Relative value={props.msLeft} updateInterval={1000} />
|
|
|
|
}} />
|
2016-05-02 13:34:23 +05:30
|
|
|
};
|