#156: add already have code for register panel

This commit is contained in:
SleepWalker 2016-07-24 11:32:54 +03:00
parent 2a9b83fe15
commit a2e8fbab95
14 changed files with 62 additions and 14 deletions

View File

@ -7,7 +7,7 @@ export default function RejectionLink(props, context) {
<a href="#" onClick={(event) => {
event.preventDefault();
context.reject();
context.reject(props.payload);
}}>
<Message {...props.label} />
</a>
@ -16,6 +16,8 @@ export default function RejectionLink(props, context) {
RejectionLink.displayName = 'RejectionLink';
RejectionLink.propTypes = {
// eslint-disable-next-line react/forbid-prop-types
payload: PropTypes.object, // Custom payload for active state
label: PropTypes.shape({
id: PropTypes.string
}).isRequired

View File

@ -1,6 +1,7 @@
{
"accountActivationTitle": "Account activation",
"activationMailWasSent": "Please check {email} for the message with the last registration step",
"activationMailWasSent": "Please check {email} for the message with further instructions",
"activationMailWasSentNoEmail": "Please check your E-mail for the message with further instructions",
"confirmEmail": "Confirm Email",
"didNotReceivedEmail": "Did not received Email?",
"enterTheCode": "Enter the code from Email here"

View File

@ -22,6 +22,7 @@ export default class ActivationBody extends BaseAuthBody {
render() {
const {key} = this.props.params;
const email = this.context.user.email;
return (
<div>
@ -31,9 +32,16 @@ export default class ActivationBody extends BaseAuthBody {
<div className={styles.descriptionImage} />
<div className={styles.descriptionText}>
<Message {...messages.activationMailWasSent} values={{
email: (<b>{this.context.user.email}</b>)
}} />
{email
? (
<Message {...messages.activationMailWasSent} values={{
email: (<b>{email}</b>)
}} />
)
: (
<Message {...messages.activationMailWasSentNoEmail} />
)
}
</div>
</div>
<div className={styles.formRow}>

View File

@ -4,6 +4,7 @@ import { Button } from 'components/ui/form';
import RejectionLink from 'components/auth/RejectionLink';
import AuthTitle from 'components/auth/AuthTitle';
import activationMessages from 'components/auth/activation/Activation.intl.json';
import forgotPasswordMessages from 'components/auth/forgotPassword/ForgotPassword.intl.json';
import messages from './Register.intl.json';
import Body from './RegisterBody';
@ -13,6 +14,12 @@ export default function Register() {
Title: () => <AuthTitle title={messages.registerTitle} />,
Body,
Footer: () => <Button color="blue" label={messages.signUpButton} type="submit" />,
Links: () => <RejectionLink label={activationMessages.didNotReceivedEmail} />
Links: () => (
<span>
<RejectionLink label={activationMessages.didNotReceivedEmail} payload={{requestEmail: true}} />
{' | '}
<RejectionLink label={forgotPasswordMessages.alreadyHaveCode} />
</span>
)
};
}

View File

@ -2,6 +2,8 @@ import React from 'react';
import { Button } from 'components/ui/form';
import AuthTitle from 'components/auth/AuthTitle';
import RejectionLink from 'components/auth/RejectionLink';
import forgotPasswordMessages from 'components/auth/forgotPassword/ForgotPassword.intl.json';
import messages from './ResendActivation.intl.json';
import Body from './ResendActivationBody';
@ -11,6 +13,6 @@ export default function ResendActivation() {
Title: () => <AuthTitle title={messages.title} />,
Body,
Footer: () => <Button color="blue" label={messages.sendNewEmail} type="submit" />,
Links: () => null
Links: () => <RejectionLink label={forgotPasswordMessages.alreadyHaveCode} />
};
}

View File

@ -1,6 +1,7 @@
{
"components.auth.activation.accountActivationTitle": "Актывацыя акаунта",
"components.auth.activation.activationMailWasSent": "На {email} высланы ліст з інструкцыямі па завяршэнні рэгістрацыі",
"components.auth.activation.activationMailWasSentNoEmail": "Please check your E-mail for the message with the last registration step",
"components.auth.activation.confirmEmail": "Пацверджанне Email",
"components.auth.activation.didNotReceivedEmail": "Не атрымалі Email?",
"components.auth.activation.enterTheCode": "Увядзіце код з Email тут",

View File

@ -1,6 +1,7 @@
{
"components.auth.activation.accountActivationTitle": "Account activation",
"components.auth.activation.activationMailWasSent": "Please check {email} for the message with the last registration step",
"components.auth.activation.activationMailWasSent": "Please check {email} for the message with further instructions",
"components.auth.activation.activationMailWasSentNoEmail": "Please check your E-mail for the message with further instructions",
"components.auth.activation.confirmEmail": "Confirm Email",
"components.auth.activation.didNotReceivedEmail": "Did not received Email?",
"components.auth.activation.enterTheCode": "Enter the code from Email here",

View File

@ -1,6 +1,7 @@
{
"components.auth.activation.accountActivationTitle": "Активация аккаунта",
"components.auth.activation.activationMailWasSent": "На {email} отправлено письмо с инструкциями по завершению регистрации",
"components.auth.activation.activationMailWasSentNoEmail": "На ваш E-mail отправлено письмо с инструкциями по завершению регистрации",
"components.auth.activation.confirmEmail": "Подтверждение Email",
"components.auth.activation.didNotReceivedEmail": "Не получили Email?",
"components.auth.activation.enterTheCode": "Укажите код из Email здесь",
@ -21,7 +22,7 @@
"components.auth.finish.copy": "Скопировать",
"components.auth.finish.passCodeToApp": "Чтобы завершить процесс авторизации, пожалуйста, передай {appName} этот код",
"components.auth.finish.waitAppReaction": "Пожалуйста, дождитесь реакции вашего приложения",
"components.auth.forgotPassword.alreadyHaveCode": "Уже получил код",
"components.auth.forgotPassword.alreadyHaveCode": "Уже есть код",
"components.auth.forgotPassword.pleasePressButton": "Нажмите на кнопку ниже, чтобы получить Email с кодом для восстановления пароля.",
"components.auth.forgotPassword.sendMail": "Отправить письмо",
"components.auth.forgotPassword.specifyEmail": "Укажите регистрационный Email адрес или последний использованный ник от вашего аккаунта, и мы отправим Email с дальнейшими инструкциями по восстановлению пароля.",

View File

@ -1,6 +1,7 @@
{
"components.auth.activation.accountActivationTitle": "Активація акаунту",
"components.auth.activation.activationMailWasSent": "На {email} відправлено повідомлення з інструкціями по завершенню реєстрації",
"components.auth.activation.activationMailWasSentNoEmail": "На ваш E-mail відправлено повідомлення з інструкціями по завершенню реєстрації",
"components.auth.activation.confirmEmail": "Підтвердження Email",
"components.auth.activation.didNotReceivedEmail": "Не отримали Email?",
"components.auth.activation.enterTheCode": "Вкажіть код з Email",
@ -21,7 +22,7 @@
"components.auth.finish.copy": "Скопіювати",
"components.auth.finish.passCodeToApp": "Щоб завершити процес авторизації, будь ласка, передайте {appName} цей код",
"components.auth.finish.waitAppReaction": "Будь ласка, дочекайтеся реакції вашої програми",
"components.auth.forgotPassword.alreadyHaveCode": "Вже отримав код",
"components.auth.forgotPassword.alreadyHaveCode": "Вже є код",
"components.auth.forgotPassword.pleasePressButton": "Натисніть на кнопку нижче, щоб отримати E-mail з кодом для відновлення пароля.",
"components.auth.forgotPassword.sendMail": "Відправити повідомлення",
"components.auth.forgotPassword.specifyEmail": "Вкажіть реєстраційну E-mail адресу або останній використаний нік від вашого облікового запису, і ми відправимо E-mail з подальшими інструкціями щодо відновлення пароля.",

View File

@ -1,5 +1,6 @@
import AbstractState from './AbstractState';
import CompleteState from './CompleteState';
import ActivationState from './ActivationState';
import ResendActivationState from './ResendActivationState';
export default class RegisterState extends AbstractState {
@ -18,7 +19,11 @@ export default class RegisterState extends AbstractState {
.then(() => context.setState(new CompleteState()));
}
reject(context) {
context.setState(new ResendActivationState());
reject(context, payload) {
if (payload.requestEmail) {
context.setState(new ResendActivationState());
} else {
context.setState(new ActivationState());
}
}
}

View File

@ -19,6 +19,10 @@ export default class ResendActivationState extends AbstractState {
.then(() => context.setState(new ActivationState()));
}
reject(context) {
context.setState(new ActivationState());
}
goBack(context) {
if (context.prevState instanceof RegisterState) {
context.setState(new RegisterState());

View File

@ -133,7 +133,7 @@ describe('AuthFlow.functional', () => {
navigate('/register');
expect(flow.state).to.be.instanceof(RegisterState);
flow.state.reject(flow);
flow.state.reject(flow, {requestEmail: true});
expect(flow.state).to.be.instanceof(ResendActivationState);
flow.state.goBack(flow);

View File

@ -1,5 +1,6 @@
import RegisterState from 'services/authFlow/RegisterState';
import CompleteState from 'services/authFlow/CompleteState';
import ActivationState from 'services/authFlow/ActivationState';
import ResendActivationState from 'services/authFlow/ResendActivationState';
import { bootstrap, expectState, expectNavigate, expectRun } from './helpers';
@ -81,10 +82,16 @@ describe('RegisterState', () => {
});
describe('#reject', () => {
it('should transition to activation', () => {
expectState(mock, ActivationState);
state.reject(context, {});
});
it('should transition to resend-activation', () => {
expectState(mock, ResendActivationState);
state.reject(context);
state.reject(context, {requestEmail: true});
});
});
});

View File

@ -97,6 +97,14 @@ describe('ResendActivationState', () => {
});
});
describe('#reject', () => {
it('should transition to activate state on reject', () => {
expectState(mock, ActivationState);
state.reject(context);
});
});
describe('#goBack', () => {
it('should transition to activation', () => {
expectState(mock, ActivationState);