import React, { ComponentType, ReactElement, ReactNode } from 'react';
import { Link } from 'react-router-dom';
import { FormattedMessage as Message } from 'react-intl';
import { RelativeTime } from 'app/components/ui';
const SuggestResetPassword: ComponentType = () => (
<>
),
}}
/>
>
);
const ResendKey: ComponentType<{ url: string }> = ({ url }) => (
<>
{' '}
>
);
const errorsMap: Record) => ReactElement> = {
'error.login_required': () => ,
'error.login_not_exist': () => (
),
'error.password_required': () => ,
'error.password_incorrect': (props) => (
// props are handled in validationErrorsHandler in components/auth/actions
<>
{props && props.isGuest ? : 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 && props.isGuest ? : null}
>
),
'error.totp_required': () => ,
'error.totp_incorrect': () => ,
'error.otp_already_enabled': () => (
),
'error.rePassword_required': () => (
),
'error.password_too_short': () => (
),
'error.rePassword_does_not_match': () => (
),
'error.rulesAgreement_required': () => (
),
'error.key_required': () => ,
'error.key_not_exists': (props) => (
<>
{props && 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': (props) => errorsMap['error.captcha_required'](props),
'error.redirectUri_required': () => ,
'error.redirectUri_invalid': () => ,
invalid_user_code: () => ,
expired_token: () => (
),
used_user_code: () => ,
};
interface ErrorLiteral {
type: string;
payload?: Record;
}
type Error = string | ErrorLiteral;
export function resolve(error: Error): ReactNode {
let payload = {};
if (typeof error !== 'string') {
payload = error.payload || {};
error = error.type;
}
return errorsMap[error] ? errorsMap[error](payload) : error;
}