import React from 'react';
import { FormattedMessage as Message, FormattedRelative as Relative } from 'react-intl';
import { Link } from 'react-router-dom';
import messages from './errorsDict.intl.json';
/* eslint-disable react/prop-types, react/display-name, react/no-multi-comp, no-use-before-define */
export default {
resolve(error) {
let payload = {};
if (error.type) {
payload = error.payload || {};
error = error.type;
}
return errorsMap[error] ? errorsMap[error](payload) : error;
}
};
const errorsMap = {
'error.login_required': () => ,
'error.login_not_exist': () => ,
'error.password_required': () => ,
'error.password_incorrect': (props = {}) => (
// props are handled in validationErrorsHandler in components/auth/actions
{props.isGuest ? errorsMap.suggestResetPassword() : null}
),
'error.username_required': () => ,
'error.username_invalid': () => ,
'error.username_too_short': () => ,
'error.username_too_long': () => ,
'error.username_not_available': () => ,
'error.email_required': () => ,
'error.email_too_long': () => ,
'error.email_invalid': () => ,
'error.email_is_tempmail': () => ,
'error.email_not_available': (props = {}) => (
// props are handled in validationErrorsHandler in components/auth/actions
{props.isGuest ? errorsMap.suggestResetPassword() : null}
),
'error.rePassword_required': () => ,
'error.password_too_short': () => ,
'error.rePassword_does_not_match': () => ,
'error.rulesAgreement_required': () => ,
'error.key_required': () => ,
'error.key_not_exists': (props) => (
{props.repeatUrl ? errorsMap.resendKey(props.repeatUrl) : null}
),
'error.key_expire': (props) => errorsMap['error.key_not_exists'](props),
'error.newPassword_required': () => ,
'error.newRePassword_required': () => ,
'error.account_not_activated': () => ,
'error.account_banned': () => ,
'error.recently_sent_message': (props) => (
}} />
),
'error.email_not_found': () => ,
'error.account_already_activated': () => ,
'error.captcha_required': () => ,
'error.captcha_invalid': () => errorsMap['error.captcha_required'](),
suggestResetPassword: () => (
)
}} />
),
resendKey: (url) => (
{' '}
)
};