mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-30 10:42:34 +05:30
#156: add already have code for register panel
This commit is contained in:
parent
2a9b83fe15
commit
a2e8fbab95
@ -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
|
||||
|
@ -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 E‑mail",
|
||||
"didNotReceivedEmail": "Did not received E‑mail?",
|
||||
"enterTheCode": "Enter the code from E‑mail here"
|
||||
|
@ -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}>
|
||||
{email
|
||||
? (
|
||||
<Message {...messages.activationMailWasSent} values={{
|
||||
email: (<b>{this.context.user.email}</b>)
|
||||
email: (<b>{email}</b>)
|
||||
}} />
|
||||
)
|
||||
: (
|
||||
<Message {...messages.activationMailWasSentNoEmail} />
|
||||
)
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.formRow}>
|
||||
|
@ -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>
|
||||
)
|
||||
};
|
||||
}
|
||||
|
@ -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} />
|
||||
};
|
||||
}
|
||||
|
@ -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": "Пацверджанне E‑mail",
|
||||
"components.auth.activation.didNotReceivedEmail": "Не атрымалі E‑mail?",
|
||||
"components.auth.activation.enterTheCode": "Увядзіце код з E‑mail тут",
|
||||
|
@ -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 E‑mail",
|
||||
"components.auth.activation.didNotReceivedEmail": "Did not received E‑mail?",
|
||||
"components.auth.activation.enterTheCode": "Enter the code from E‑mail here",
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"components.auth.activation.accountActivationTitle": "Активация аккаунта",
|
||||
"components.auth.activation.activationMailWasSent": "На {email} отправлено письмо с инструкциями по завершению регистрации",
|
||||
"components.auth.activation.activationMailWasSentNoEmail": "На ваш E-mail отправлено письмо с инструкциями по завершению регистрации",
|
||||
"components.auth.activation.confirmEmail": "Подтверждение E‑mail",
|
||||
"components.auth.activation.didNotReceivedEmail": "Не получили E‑mail?",
|
||||
"components.auth.activation.enterTheCode": "Укажите код из E‑mail здесь",
|
||||
@ -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 с дальнейшими инструкциями по восстановлению пароля.",
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"components.auth.activation.accountActivationTitle": "Активація акаунту",
|
||||
"components.auth.activation.activationMailWasSent": "На {email} відправлено повідомлення з інструкціями по завершенню реєстрації",
|
||||
"components.auth.activation.activationMailWasSentNoEmail": "На ваш E-mail відправлено повідомлення з інструкціями по завершенню реєстрації",
|
||||
"components.auth.activation.confirmEmail": "Підтвердження E‑mail",
|
||||
"components.auth.activation.didNotReceivedEmail": "Не отримали E‑mail?",
|
||||
"components.auth.activation.enterTheCode": "Вкажіть код з E‑mail",
|
||||
@ -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 з подальшими інструкціями щодо відновлення пароля.",
|
||||
|
@ -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) {
|
||||
reject(context, payload) {
|
||||
if (payload.requestEmail) {
|
||||
context.setState(new ResendActivationState());
|
||||
} else {
|
||||
context.setState(new ActivationState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
|
@ -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});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user